<%@page import="com.sq.partner.manager.util.StrUtil"%>
<%@page import="java.sql.Struct"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
	<title>投保方案新增</title>
	<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
	<script src="js/jquery.validate.js" type="text/javascript" ></script>
	<script src="js/jquery.divbox.js" type="text/javascript"></script>
	<script src="js/json2.js" type="text/javascript"></script>
	<script src="js/nlifePlanConfig.js" type="text/javascript"></script>
	<!--
            单个jsp页面代码量太大了，
            只打开编辑器都非常吃力，
            建议后续开发的内容，
            JS写在 nlifePlanConfig.js中，
            后续有机会尽量将重复代码块精简一下
            RESPECT
     -->
	<style type="text/css">
		.input_text{width:180px;}
		.select_1{width:180px;}
		#agentInfoRela3Table{
			margin: auto;
		}
		#agentInfoRela7Table{
			margin: auto;
		}
		#agentInfoRela4Table{
			margin: auto;
		}
		#agentInfoRela3Table td{
			border: 1px solid #bbcddb;
			height:15px;
			line-height:15px;
		}
		#agentInfoRela7Table td{
			border: 1px solid #bbcddb;
			height:15px;
			line-height:15px;
		}
		#agentInfoRela4Table td{
			border: 1px solid #bbcddb;
			height:15px;
			line-height:15px;
		}
		#agentInfoRela6Table td{
			text-align: center;
		}
		#agentInfoRela5Table td{
			text-align: center;
		}
	</style>

</head>

<script type="text/javascript">
	//自定义map功能
	function Map(){
		this.elements = new Array();
		//获取MAP元素个数
		this.size = function() {
			return this.elements.length;
		};
		//判断MAP是否为空
		this.isEmpty = function() {
			return (this.elements.length < 1);
		};
		//删除MAP所有元素
		this.clear = function() {
			this.elements = new Array();
		};
		//向MAP中增加元素（key, value)
		this.put = function(_key, _value) {
			if(this.containsKey(_key)){
				this.remove(_key);
				this.elements.push( {
					key : _key,
					value : _value
				});
			}else{
				this.elements.push( {
					key : _key,
					value : _value
				});
			}
		};
		//删除指定KEY的元素，成功返回True，失败返回False
		this.remove = function(_key) {
			var bln = false;
			try {
				for (var i = 0; i < this.elements.length; i++) {
					if (this.elements[i].key == _key) {
						this.elements.splice(i, 1);
						return true;
					}
				}
			} catch (e) {
				bln = false;
			}
			return bln;
		};
		//获取指定KEY的元素值VALUE，失败返回NULL
		this.get = function(_key) {
			try {
				for (var i = 0; i < this.elements.length; i++) {
					if (this.elements[i].key == _key) {
						return this.elements[i].value;
					}
				}
			} catch (e) {
				return false;
			}
			return false;
		};
		//判断MAP中是否含有指定KEY的元素
		this.containsKey = function(_key) {
			var bln = false;
			try {
				for (var i = 0; i < this.elements.length; i++) {
					if (this.elements[i].key == _key) {
						bln = true;
					}
				}
			} catch (e) {
				bln = false;
			}
			return bln;
		};
		//获取map的所有values
		this.values = function() {
			var arr = new Array();
			for (var i = 0; i < this.elements.length; i++) {
				arr.push(this.elements[i].value);
			}
			return arr;
		};
		//获取map的所有keys
		this.keys= function() {
			var arr = new Array();
			for (var i = 0; i < this.elements.length; i++) {
				arr.push(this.elements[i].key);
			}
			return arr;
		};
		//获取数组
		this.getArray= function(){
			var arr = new Array();
			for (var i = 0; i < this.elements.length; i++) {
				arr.push({
					key : this.elements[i].key,
					value : this.elements[i].value
				});
			}
			return arr;
		};
	}
	//********************************************

	var map = new Map();
	var map1 = new Map();
	var mapBak = new Map();
	var zonMap=new Map();
	var emailMap=new Map();
	var agentInfoList = new Array();
	var salemap=new Map();
	var rolemap=new Map();
	var oldAgentType = '';//复制新增时的原agentType
	var oldPartnerNo='';//复制新增时的原partnerNo;
	var iscopy=false;
	var channelFlag="";
	$(function(){
		<c:choose>
		<c:when test="${not empty planNo || not empty oldPlanNo}">
		//编辑/复制新增 时，才需进行的初始化操作
		init();
		</c:when>
		<c:otherwise>
		$("#dicputeType").val("2");
		$("#saveNlifePlanBtn").click(function(){
			checkAndExcute('add');

		});
		</c:otherwise>
		</c:choose>
		emailTemplate();
	});

	function init(){
		var flag=false;

		<c:choose>
		<c:when test="${not empty planNo}">
		$("#saveNlifePlanBtn").click(function(){
			checkAndExcute('update');
		});
		</c:when>
		<c:when test="${not empty oldPlanNo}">
		flag=true;
		iscopy=true;
		$("#saveNlifePlanBtn").click(function(){
			checkAndExcute('copyAdd');
		});
		$('#planNo').css('color','#ccc');//复制新增，隐藏方案号的显示
		$('#checkOpinion').css('color','#ccc');//复制新增，隐藏审核意见的显示
		</c:when>
		</c:choose>
		var planNo = $.trim($('#hidePlanNo').val());
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/loadNlifePlan?"+new Date().getTime(),
			type : 'POST',
			async : false,
			data:{planNo:planNo},
			dataType:'json',
			success:function(data){
				if($.validate(data))return;
				var nlifePlan = data.nlifePlan;
				var nlifeProd = data.nlifeProd;
				var nlifeCoreProd = data.nlifeCoreProd;
				oldAgentType = nlifePlan.agentType;
				oldPartnerNo = nlifePlan.partnerNo;
				$('#planNo').val(nlifePlan.planNo);
				$("#agentType").val(nlifePlan.agentType);
				$('#planName').val(nlifePlan.planName);
				$('#prodCode').val(nlifePlan.prodCode);
				$('#prodSaleCode').val(nlifeCoreProd.prodSaleCode);
				$('#partnerNo').val(nlifePlan.partnerNo);
				//加载方案名称与方案号
				document.getElementById("unionMessageConfigPlanNoTitle").innerHTML += nlifePlan.planNo;
				document.getElementById("unionMessageConfigPlanNameTitle").innerHTML += nlifePlan.planName;
				$('#isRiskQuery').val(nlifePlan.isRiskQuery);
				$('#isAfterPay').val(nlifePlan.isAfterPay);
				$('#isAddedService').val(nlifePlan.isAddedService);
				$('#addedServiceCode').val(nlifePlan.addedServiceCode);
				$('#addedServiceName').val(nlifePlan.addedServiceName);
				$('#addedServiceCount').val(nlifePlan.addedServiceCount);
				$('#serviceTypeSelect').val(nlifePlan.serviceType);
				$('#channleCode_QD').val(nlifePlan.channleCode);
				$('#mfacadeIsReInsure').val(nlifePlan.mfacadeIsReInsure);
                $('#isPushedSalesInfo').val(nlifePlan.isPushedSalesInfo);
				/* changeChannleCode_QD(); */
				$('#channleType').val(nlifePlan.channleType);
				$('#newBsnsType').val(nlifePlan.newBsnsType);
				$('#bsnsType').val(nlifePlan.categoryCode);
				$('#isThirdPlan').val(data.thirdPlan);
				$('#marketPreserveRate').val(nlifePlan.marketPreserveRate);
				$('#businessPerformanceRate').val(nlifePlan.businessPerformanceRate);
				$('#checkOpinion').val(nlifePlan.checkOpinion);
				$('#commRate').val(nlifePlan.commRate);
				$('#businessNature3').val(nlifePlan.businessNature3);
				$('#greenIndustryFirst').val(nlifePlan.greenIndustryFirst);
				$('#greenIndustrySecond').val(nlifePlan.greenIndustrySecond);
				//燕赵二次新增字段
				$('#otherRate').val(nlifePlan.otherRate);
				$('#businessNature1').val(nlifePlan.businessNature1);
				$('#businessNature2').val(nlifePlan.businessNature2);
				if(nlifePlan.txChannel != null ){
					$('#txChannel1st').val(nlifePlan.txChannel.substring(0,2));
					$('#txChannel2nd').val(nlifePlan.txChannel);
				}
				$('#tkFlag').val(nlifePlan.tkFlag);
				$('#regressDept').val(nlifePlan.regressDept);
				$('#operatorNo').val(nlifePlan.operatorNo);
				
				
				$("tr[id^=agentType1]").css('display','none');
				$("tr[id^=agentType3]").css('display','none');
				$("tr[id^=agentType4]").css('display','none');
				$("tr[id^=agentType5]").css('display','none');
				$("tr[id^=agentType6]").css('display','none');
				$("tr[id^=agentType7]").css('display','none');
				$("tr[id^=agentType8]").css('display','none');
				var isbanchs=data.isBanchs;
				channelFlag=data.planChannelInfo.channelFlag;
				channelChannel(channelFlag);
				if(isbanchs){
					$('input[onclick!="openAgentInfo4Div()"][onclick!="openAgentInfoZon4Div()"][onclick!="openAgentInfoZon5Div()"][onclick!="clearAgentInfoZon4Div()"][onclick!="clearAgentInfoZon5Div()"][id!=GoBackNlifePlanBtn][id!=cancelBtn][id!=branch][id!=branchName][onclick!="queryAgentInfo4(1)"][onclick!="saveChosenAgentInfo4(1)"][onclick!="saveChosenAgentInfo4()"]').attr("disabled",true);
					$('input[onclick!="openAgentInfo4Div()"][onclick!="openAgentInfoZon4Div()"][onclick!="openAgentInfoZon5Div()"][onclick!="clearAgentInfoZon4Div()"][onclick!="clearAgentInfoZon5Div()"][id!=GoBackNlifePlanBtn][id!=cancelBtn][id!=branch][id!=branchName][onclick!="queryAgentInfo4(1)"][onclick!="saveChosenAgentInfo4(1)"][onclick!="saveChosenAgentInfo4()"]').css("background-color","#ccc");
					$('select[id!=confStatus_4]').attr("disabled",true);
					$('select[id!=confStatus_4]').css("background-color","#ccc");
					$('textarea').attr("disabled",true);
					$("input[onclick='openAgentInfoZon4Div()']").css('display','none');
					$("input[onclick='clearAgentInfoZon4Div()']").css('display','none');
					$("input[onclick='openAgentInfoZon5Div()']").css('display','none');
					$("input[onclick='clearAgentInfoZon5Div()']").css('display','none');
					$("#SendAccessoryBox").click(function(){
						return false;
					})
				}
				emailTemplate();
				//是否电子保单
				if(nlifeProd.epolicyCode!=null&&nlifeProd.epolicyCode!=''){
					$("#iseplicyFlag").val(nlifeProd.epolicyCode+'-'+nlifeProd.epolicyName);
				}
				if(nlifeProd.epolicyName==null||nlifeProd.epolicyName==''){
					nlifeProd.epolicyName='未知';
				}
				$('#propTitle').html("保单模板："+nlifeProd.epolicyCode+'-'+nlifeProd.epolicyName)
				isDisable("agentType", true);
				// 3、个人代理4、总对总代理 5、联合出单代理1、合作伙伴代理
				if("3"==nlifePlan.agentType){}else if("4"==nlifePlan.agentType){}else if("5"==nlifePlan.agentType){}
				else if("6"==nlifePlan.agentType ){}else if("7"==nlifePlan.agentType){}else if("8"==nlifePlan.agentType){}else{
					$('#empNo').val(nlifePlan.empNo);
					$('#empName').val(nlifePlan.empName);
					$('#teamCode').val(nlifePlan.teamCode);
					$('#teamName').val(nlifePlan.teamName);
					$('#agentNo').val(nlifePlan.agentNo);
					$('#agentName').val(nlifePlan.agentName);
					$('#protocolNo').val(nlifePlan.protocolNo);
					$('#serviceCode').val(nlifePlan.serviceCode);
					$('#serviceName').val(nlifePlan.serviceName);

					$("tr[id^=quDao0]").css('display','');
					$("tr[id^=agentType1]").css('display','');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode101").append("出单机构：");
					$("#deptCode102").append("<input id='dptCde' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;&nbsp;<input type='button' class='input_button_2' value='请选择' onClick='openDeptDiv()' />");
					$('#dptCde').val(nlifePlan.dptCde);
				}
				//短信模板、短信接收人动态显示
				if(nlifePlan.isMessage=='Y'){
					$('#messageTemplateTr').show();
					$('#messageReceiverDiv').show();
					$('#messageReceiver').val(nlifePlan.messageReceiver);
					$('#smsTemplateDiv').show();
					$('#messageTemplate').attr("disabled",true).css("background-color","rgb(204, 204, 204)").val(data.messageTemplate_val);
					$('#smsTemplateDiv').show();
					$('#smsTemplate').val(nlifePlan.messageTemplate);
				}

				//注销短信模板、短信接收人动态显示
				$('#isCancelMessage').val(nlifePlan.isCancelMessage);
				if(nlifePlan.isCancelMessage=='Y'){
					$('#cancelTemplateTr').show();
					$('#cancelReceiverDiv').show();
					$('#cancelReceiver').val(nlifePlan.cancelReceiver);
					$('#cancelTemplate').attr("disabled",true).css("background-color","rgb(204, 204, 204)").val(data.cancelTemplate_val);
					$('#cancelTemplateDiv').show();
					$('#isCancelTemplate').val(nlifePlan.cancelTemplate);
				}
				//是否回执动态显示
				$('#isReceipt').val(nlifePlan.isReceipt);
				if(nlifePlan.isReceipt=='Y'){
					$('#isOrNotDisplayReceiptTypeDiv').show();
					$('#receiptType').val(nlifePlan.receiptType);
				}
				//是否分期动态显示
				$('#isPayment').val(nlifePlan.isPayment);
				if(nlifePlan.isPayment=='Y'){
					$('#isOrNotDisplayPaymentTypeDiv').show();
					$('#paymentType').val(nlifePlan.paymentType);
				}

				//状态字段的动态显示
				$('#state').val(nlifePlan.state);
				if(flag){
					$('#state').val("1");
					$('input[onclick!="openAgentInfo3Div()"][onclick!="openAgentInfo4Div()"][onclick!="openAgentInfo5Div()"][onclick!="openAgentInfo6Div(1)"][onclick!="openAgentInfoZon4Div()"][onclick!="openAgentInfoZon5Div()"][onclick!="clearAgentInfoZon4Div()"][onclick!="clearAgentInfoZon5Div()"]').attr("disabled",false);
					$('input').css("background-color","");
					$('select').attr("disabled",false);
					$('select').css("background-color","");
					$('#state').attr("disabled",true);
					$('#state').css("background-color","#ccc");
					$('textarea').attr("disabled",false);
					$('textarea').css("background-color","");
					$('#MailTemplate').attr("disabled",true);
					$('#MailTemplate').css("background-color","rgb(204, 204, 204)");
					$('#cancelTemplate').attr("disabled",true).css("background-color","rgb(204, 204, 204)");
					$('#messageTemplate').attr("disabled",true).css("background-color","rgb(204, 204, 204)");
					$('#saveNlifePlanBtn').attr("disabled",false);
					$('#saveNlifePlanBtn').css("background-color","");
					$('#GoBackNlifePlanBtn').attr("disabled",false);
					$('#GoBackNlifePlanBtn').css("background-color","");
					$('#checkOpinion').attr("disabled",true);
					$('#checkOpinion').css("background-color","#ccc");
					$('#planNo').attr("disabled",true);
					$('#planNo').css("background-color","#ccc");
					$('#prodCode').attr("disabled",true);
					$('#prodCode').css("background-color","#ccc");
					$('#partnerNo').attr("disabled",true);
					$('#partnerNo').css("background-color","#ccc");
					$('#dptCde').attr("disabled",true);
					$('#dptCde').css("background-color","#ccc");
					isDisable("agentFeeConfig", true);
					if('6'==nlifePlan.agentType || '4'==nlifePlan.agentType || '8'==nlifePlan.agentType){
						isDisable("agentFeeConfig", false);
						agentFeeConfigChange();
					}
				}
				//争议解决方式
				$("#dicputeType").val(nlifePlan.dicputeType);
				if(nlifePlan.dicputeType!=2){
					$("#arbitrationDept").attr("disabled",true);
					$("#arbitrationDept").hide();
				}else{
					$("#arbitrationDept").val(nlifePlan.arbitrationDept);
					$("#arbitrationDept").show();
				}

				//争议解决方式结束
				$('#specialArran').val(nlifePlan.specialArran);
				$('#isSeeMoney').val(nlifePlan.isSeeMoney);
				$('#isEpolicy').val(nlifePlan.isEpolicy);
				$('#notice').val(nlifePlan.notice);
				$('#isMedicalMessage').val(nlifePlan.isMedicalMessage);

				if(nlifePlan.isSeeMoney== "N"){
				}else if(nlifePlan.isSeeMoney== "YD"){
					$("#notice_1").show();
				}
				$("#dentification").val(nlifePlan.dentification);
				//是不是发送邮件
				if(nlifePlan.isSendEmail==''||nlifePlan.isSendEmail==null){
					$('#isEpolicyMali').val(2);
				}else{
					$('#isEpolicyMali').val(nlifePlan.isSendEmail);
				}

				if((nlifePlan.isSendEmail)==0||(nlifePlan.isSendEmail)==2){
					$('#MailTemplateTr').hide();
					$('#sendAccessory').show();
					$('#sendAccessoryTd').show();
					$('input[name=SendAccessoryBox]').attr('disabled',true);
				}
				if((nlifePlan.isSendEmail)=="1"){
					$('#sendAccessory').show();
					$('#sendAccessoryTd').show();
					$('#MailTemplateTr').show();
					$('input[name=SendAccessoryBox]').attr('disabled',false);
					$('#MailTemplate').val(nlifePlan.emailTemplate);
					var ids=new Array(5);
					ids=data.ids;
					if(ids!=null){
						$('input[name=SendAccessoryBox]').each(function(){
							for(i=0;i<ids.length;i++){
								if($(this).val()==ids[i]){
									$(this).attr("checked",true);

								}
							}
						});
					}
				}
				$('#DownloadWay').val(nlifePlan.epolicyDownloadWay);
				downloadWayChange('1');
				$('#fileType').val(nlifePlan.fileType);


				//续保费用比例差值回写

				$('#rateSubtract').val(nlifePlan.rateSubtract);
				queryUpdateInformation($("#prodCode").val());
				prodCodeChanged($("#prodCode").val());
			}
		});


	}
	function dicputeType1(){
		var dicpute=$("#dicputeType").val();
		if(dicpute=='2'){
			$("#arbitrationDept").attr("disabled",false);
			$("#arbitrationDept").show();
		}else {
			$("#arbitrationDept").attr("disabled",true);
			$("#arbitrationDept").hide();
		}
	}
	//跟单费用配置选择保存
	function saveChosenAgentInfo6(){
		var selectedAgentInfo6 = $("input[name='agentInfo6radioBox']:checked");
		if(selectedAgentInfo6.val()==undefined){
			$.message("error","请选中一项");
			return ;
		}
		var agentNo=selectedAgentInfo6.parent().parent().children("td:eq(1)").html();
		var planNo=$.trim($('#hidePlanNo').val());
		var prodCode=$("#prodCode").val();
		var resultCode = isSaveCoinFeeConfig(agentNo);
		if("01" == resultCode){
			$.message("error","有跟单费用配置大于条款上限");
			return ;
		}
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/saveCoinPlan?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				agentNo:agentNo,
				planNo:planNo
			},
			dataType:'json',
			success:function(data){
				$.closeLoading();
				if(data.success){
					$.message("success","添加成功");
					closeAgentInfoDiv("agentInfo6Div");
					queryAgentInfoRela6(1);
				}else{
					$.message("error","添加失败请重试");
				}
			}
		});

	}//跟单费用配置选择保存结束
	function getSale(i){
		var roles=rolemap.get("role");
		var hr='<select id="saleMentype'+i+'" class="select_1 valid" style=" width: 130px">'
				+'<option value="">请选择</option>'
		for (var j = 0; j < roles.length; j++) {
			hr+='<option value="'+roles[j].code+'">'+roles[j].codeName+'</option>'
		}
		hr+='</select>';
		return hr;
	}
	//接口传入方案打开div
	function openAgentInfo6Div(currunt){
		loadAgentInfo6({current:currunt,size:10})
	}
	function queryAgentInfo6(currunt){
		var agentNo=$('#agentNoSer').val();
		var agentName=$('#agentNameSer').val();
		loadAgentInfo6({current:currunt,size:10,agentNo:agentNo,agentName:agentName})
	}
	//加载总对总代理信息
	function loadAgentInfo6(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifeSaleConfig/querySalePageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if(page.data==null){
					$.message("error","请配置跟单费用配置信息");
					return ;
				}
				var checkboxObj ="<input name='agentInfo6radioBox' type='radio'>";
				var fieldNames ="AGENT_NO,AGENT_NAME";
				var tableContent = creatTable1(fieldNames,page,checkboxObj);
				var tableObj = $("#agentInfo6Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				var strPage = creatChannelPage4(param.current,6,page.maxPage,"63");
				var pageDIV = $("#agentInfo6Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);

				$('#agentInfo6Div').OpenDiv();

				bindradio();
			}
		});
	}
	//销售人员信息
	function opensaleDiv(){
		if(!rolemap.get("role")){
			$.ajax({
				url : "<%=path%>/nlifePlanConfig/loadDic",
				type : 'POST',
				async : true,
				data:{},
				dataType:'json',
				success:function(data){
					rolemap.put("role", data.roleStype);
					createSale();
				}
			});
		}else {
			createSale();
		}
	}
	function createSale(){
		var salecontent=''
		for (var i = 1; i <= 5; i++) {
			salecontent+='<tr>'+
					'<td>'+i+'<input type="hidden" id="flag'+i+'" value="'+i+'"/></td>'+
					'<td>'+
					getSale(i)+
					'</td>'+
					'<td><input type="text" id="saleMen'+i+'"  class="input_text" style=" width: 130px"/></td>'+
					'<td><input type="text" id="saleName'+i+'"  class="input_text" style=" width: 130px"/></td>'+
					'<td><input type="text"  id="permitNo'+i+'" style=" width: 130px"/></td>'+
					'<td><input type="text"  id="agentCode'+i+'" style=" width: 130px"/></td>'+
					'<td><input type="text" id="agentName'+i+'"  class="input_text" style=" width: 130px"/></td>'+
					'<td><input type="text" id="costRate'+i+'"  class="input_text" onkeyup="clearNoNum(event,this)" style=" width: 130px"/></td>'+
					'</tr>'
		}
		$('#salecontent').html('');
		$('#salecontent').html(salecontent);
		$('#sale_div').OpenDiv()
		//赋值
		for (var i = 1; i <=5; i++) {
			var o=salemap.get(i);
			if(o){
				$('#flag'+i).val(o.seqNo);
				$('#permitNo'+i).val(o.permitNo);
				$('#agentCode'+i).val(o.agentCode);
				$('#agentName'+i).val(o.agentName);
				$('#saleMentype'+i).val(o.saleType);
				$('#saleMen'+i).val(o.salePerson);
				$('#saleName'+i).val(o.saleName);
				$('#costRate'+i).val(parseFloat(o.costRate).toFixed(2))
			}
		}
	}
	//销售人员信息保存
	function  saveSale(){
		var salemap1=new Map();
		var salemap2=new Map();
		var arr1 = new Array();
		for (var i = 1; i <= 5; i++) {
			var flag=0;
			var j=0;
			var o=new Object();
			//职业证号
			var seqNo=$('#flag'+i).val();
			o.seqNo=seqNo;
			var permitNo=$('#permitNo'+i).val();
			if($.trim(permitNo)!=''){
				o.permitNo=permitNo;
				flag=flag+1;
			}
			//销售人员类别
			var saleType=$('#saleMentype'+i).val();
			var saleTypeName= $('#saleMentype'+i).find("option:selected").text();
			if(saleType!=''){
				o.saleType=saleType;
				o.saleTypeName=saleTypeName;
				j=j+1;
				flag=flag+1;
			}
			//销售人员代码
			var saleMen=$('#saleMen'+i).val();
			if($.trim(saleMen)!=''){
				o.salePerson=saleMen;
				j=j+1;
				flag=flag+1;
			}
			//销售人员名称
			var saleName=$('#saleName'+i).val();
			if($.trim(saleName)!=''){
				o.saleName=saleName;
				flag=flag+1;
			}
			//费用比例
			var costRate=$('#costRate'+i).val();
			if($.trim(costRate)!=''){
				o.costRate=costRate;
				j++;
				flag=flag+1;
			}
			//代理人机构号
			var agentCode=$('#agentCode'+i).val();
			if($.trim(agentCode)!=''){
				o.agentCode=agentCode;
				flag=flag+1;
			}
			//代理人机构名称
			var agentName=$('#agentName'+i).val();
			if($.trim(agentName)!=''){
				o.agentName=agentName;
				flag=flag+1;
			}
			if(j>=1&&j!=3){
				$.message("error","序号为"+i+"的数据存在必填项未填写，请填写");
				return;
			}
			if($.trim(costRate)!=''){
				if(i!=1){
					var o1=salemap1.get(i-1);
					if(o1==null||o1==undefined||o1==false){
						$.message("error","序号为"+i+"的上一个序号未填写不能跳号");
						return;
					}
				}
				salemap1.put(i,o);
			}
			if($.trim(costRate)!=''){
				arr1.push(o);
			}
		}
		var rate=0;
		for (var i = 1; i <= 5; i++) {
			if(salemap1.get(i).costRate==''||salemap1.get(i).costRate==undefined){
			}else{
				var rate1=salemap2.get(salemap1.get(i).saleType);
				if(rate1){
					salemap2.put(salemap1.get(i).saleType,parseFloat(salemap1.get(i).costRate)+parseFloat(rate1));
				}else{
					salemap2.put(salemap1.get(i).saleType,parseFloat(salemap1.get(i).costRate));
				}
			}
		}
		if(salemap2){
			for(i in salemap2.keys()){
				var key = salemap2.keys()[i];
				if(salemap2.get(key)!="1"){
					$.message("error", "相同人员分摊比例之和是1");
					return;
				}
			}
		}
		var insplanno =$.trim($('#hidePlanNo').val());
		var flag=true;
		$.openLoading();
		if(insplanno!=null&&insplanno!=""&&!iscopy){
			var arr=JSON.stringify(arr1);
			$.ajax({
				url : "<%=path%>/nlifePlanConfig/addTradPlanSale",
				type : 'POST',
				async : true,
				data:{
					planCode:insplanno,
					planType:'3',
					saleArry:arr
				},
				dataType:'json',
				success:function(result){
					if(result.result=='success'){
						$.closeLoading();
						salemap.clear();
						salemap=salemap1;
						saleTable();
						closeNocarAgentTypeDiv('sale_div');
						$.message("success", "添加成功");
					}else{
						$.message("error", "添加失败");
					}
				}
			});
		}else{
			$.closeLoading();
			salemap.clear();
			salemap=salemap1;
			saleTable();
			closeNocarAgentTypeDiv('sale_div');
			$.message("success", "添加成功");

		}
	}
	function clearNoNum1(event,obj){
		obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符
		obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
		obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
		obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数
		if(obj.value.indexOf(".")< 0 && obj.value !=""){//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
			obj.value= parseFloat(obj.value);
		}
	}
	//统一 关闭  窗口
	function closeNocarAgentTypeDiv(obj){
		$("#"+obj).CloseDiv();
	}
	//销售人员信息
	function getSaleType(saleType){
		if(saleType=='1'){
			return '内部销售人员'
		}else if(saleType=='2'){
			return '外部销售人员'
		}
		return ''
	}
	//销售人员类别
	function getSaleType1(saleType){
		if(saleType=='1'){
			return '业务员'
		}else if(saleType=='2'){
			return '销售人员'
		}else if(saleType=='7'){
			return '渠道人员'
		}
		return ''
	}
	//销售人员table
	function saleTable(){
		$('#saleShowDiv').html('');
		var ht='';
		for (var i = 1; i <=5; i++) {
			var o=salemap.get(i);
			if(o.agentCode==undefined){
				o.agentCode='';
			}
			if(o.agentName==undefined){
				o.agentName='';
			}
			if(o.permitNo==undefined){
				o.permitNo='';
			}
			if(o.saleName==undefined){
				o.saleName='';
			}
			if(o){
				ht+='<tr>'+
						'<td style="width:100px;text-align: center;">'+o.seqNo+'</td>'+
						'<td style="width:100px;text-align: center;">'+o.saleTypeName+'</td>'+
						'<td style="width:100px;text-align: center;">'+o.salePerson+'</td>'+
						'<td style="width:100px;text-align: center;">'+o.saleName+'</td>'+
						'<td style="width:100px;text-align: center;">'+o.permitNo+'</td>'+
						'<td style="width:100px;text-align: center;">'+o.agentCode+'</td>'+
						'<td style="width:100px;text-align: center;">'+o.agentName+'</td>'+
						'<td style="width:100px;text-align: center;">'+parseFloat(o.costRate)+'</td>'
			}
		}
		$('#saleShowDiv').html(ht);
	}

	//下拉框处理
	function loadSubCascadeList(codeType,parentCode,select_id){
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/loadSubCascadeList?"+new Date().getTime(),
			type : 'POST',
			async : false,
			data:{codeType:codeType,parentCode:parentCode},
			dataType:'json',
			success:function(list){
				if($.validate(list))  return;
				var select = document.getElementById(select_id);
				select.options.length = 0;
				if (list != null) {
					for (var i = 0; i < list.length; i++) {
						var option = new Option();
						option.text = list[i].codeName;
						option.title = list[i].codeName;
						option.value = list[i].code;
						select.add(option);
					}
				}
			}
		});
	}

	//选择注销短信模板展示文本内容
	function changeIsCacelTemplate(){
		var value = $('#isCancelTemplate').val();
		if(value ==null || "" == value || "0" == value){
			$('#cancelTemplate').val("");
			return false;
		}
		$.ajax({
			url	: "<%=path%>/nlifePlanConfig/loadTemplate",
			type : 'POST',
			async : true,
			dataType : 'json',
			data:{smsTemplateCode:value},
			success: function(date){
				$('#cancelTemplate').val(date.smsTemplateText);
			}
		});
	}


	//如果方案“状态”为有效，则方案整体页面内容为只读，不可修改（'状态'字段可编辑）；
	//如果方案再置位回无效，页面返回无效页面可读状态。
	function changeState(){
		var state = $.trim($('#state').val());
		if(state=="1"){
			$('input').attr("disabled",true);
			$('input').css("background-color","#ccc");
			$('select').attr("disabled",true);
			$('select').css("background-color","#ccc");
			$('#state').attr("disabled",false);
			$('#state').css("background-color","");
			$('textarea').attr("disabled",true);
			$('textarea').css("background-color","#ccc");
			$('#saveNlifePlanBtn').attr("disabled",false);
			$('#saveNlifePlanBtn').css("background-color","");
			$('#GoBackNlifePlanBtn').attr("disabled",false);
			$('#GoBackNlifePlanBtn').css("background-color","");
		}else{
			$('input').attr("disabled",false);
			$('input').css("background-color","");
			$('select').attr("disabled",false);
			$('select').css("background-color","");
			$('textarea').attr("disabled",false);
			$('textarea').css("background-color","");
			$('#planNo').attr("disabled",true);
			$('#planNo').css("background-color","#ccc");
			$('#prodCode').attr("disabled",true);
			$('#prodCode').css("background-color","#ccc");
			$('#partnerNo').attr("disabled",true);
			$('#partnerNo').css("background-color","#ccc");
			$('#dptCde').attr("disabled",true);
			$('#dptCde').css("background-color","#ccc");
			$('#agentNo').attr("disabled",true);
			$('#agentNo').css("background-color","#ccc");
			$('#agentName').attr("disabled",true);
			$('#agentName').css("background-color","#ccc");
			$('#protocolNo').attr("disabled",true);
			$('#protocolNo').css("background-color","#ccc");
			/* 	$('#isDredgePay').attr("disabled",true);
                $('#isDredgePay').css("background-color","#ccc"); */
			$('#checkOpinion').attr("disabled",true);
			$('#checkOpinion').css("background-color","#ccc");
		}
	}
	//点击"请选择(产品)" 弹出产品选择层
	function openNlifeProdDiv(){
		//加载第一页产品信息
		queryNlifeProd(1);
	}

	//加载产品信息前，拼接参数
	function queryNlifeProd(pageIndex){
		var size = 8;
		var prodCode = $.trim($('#prodCode_choose').val());
		var prodName = $.trim($('#prodName_choose').val());
		var DateReg = /^(\d{4})\-(\d{2})\-(\d{2})$/;
		var startDateBegin = $.trim($('#startDateBegin').val());
		var startDateEnd = $.trim($('#startDateEnd').val());
		var sflag = DateReg.test(startDateBegin);
		var eflag = DateReg.test(startDateEnd);
		if(null != startDateBegin && "" != startDateBegin){
			if(!sflag){
				$.message("error", "您输入的定义起期格式不正确，格式为：YYYY-MM-DD。请重新选择日期");
				$('#startDateBegin').val('');
				return;
			}
		}
		if(null != startDateEnd && "" != startDateEnd){
			if(!eflag){
				$.message("error", "您输入的定义止期格式不正确，格式为：YYYY-MM-DD。请重新选择日期");
				$('#startDateEnd').val('');
				return;
			}
		}
		loadNlifeProd({size:size,current:pageIndex,prodCode:prodCode,prodName:prodName,startDateBegin:startDateBegin,startDateEnd:startDateEnd});
	}

	//根据传入的参数，加载相应的产品
	function loadNlifeProd(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryNlifeProdPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;

				var radioObj ="<input class='input_fxk' name='radioNlifeProd' type='radio'/>";
				var fieldNames = "PROD_CODE,PROD_NAME,AGENT_TYPE@TDH,PROD_SALE_CODE@TDH,EPOLICYCODE@TDH,PROD_TYPE@TDH";
				var tableContent = creatTable1(fieldNames,page,radioObj);
				var tableObj = $("#nlifeProdTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage(param.current,6,page.maxPage,"43");
				var pageDIV = $("#nlifeProdPageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);

				$("#nlifeProdDiv").OpenDiv();

				bindradio();
			}
		});
	}
	//点击“确定”按钮，选择产品
	function chooseNlifeProd(){
		var selected = $("input[name='radioNlifeProd']:checked");
		if(selected.length==0){
			$.message("error", "请选择一个产品");
			return;
		}
		var prodCode_current = $.trim($('#prodCode').val());

		var prodType = selected.parent().parent().children(" td:eq(6)").html();
		if("3006"==prodType){
			$('#isSeeMoney').val('Y');
			isDisable("isSeeMoney", true);
		}else{
			isDisable("isSeeMoney", false);
		}
		var prodCode = selected.parent().parent().children(" td:eq(1)").html();
		$('#prodCode').val(prodCode);
		var prodSaleCode = selected.parent().parent().children(" td:eq(4)").html();
		//燕赵新增：查询该产品的升级产品的数量，加载特约录入框体
		queryUpdateInformation($("#prodCode").val());
		$('#prodSaleCode').val(prodSaleCode);//该值是为了向销管获取代理信息时传参
		//$("#iseplicyFlag").val(iseplicyFlag)
		if(prodCode != prodCode_current && iscopy !=true){//如果产品更换
			prodCodeChanged(prodCode_current);
		}
		closeNlifeProdDiv();
	}
	/**跟单费用配置改变**/
	function agentFeeConfigChange(){
		var agentFeeConfig =$('#agentFeeConfig').val();
		var agentType =$('#agentType').val();
		/**接口传入*/
		if('1'==agentFeeConfig && '4'!=agentType){
			inputBtn();
			$('#empNo').val('');
			$('#empName').val('');
			$('#teamName').val('');
			$('#teamCode').val('');
			$('#agentNo').val('');
			$('#agentName').val('');
			$('#protocolNo').val('');
			$('#serviceCode').val('');
			$('#serviceName').val('');
			$('#channleCode_QD').val('');
			$('#channleType').val('');
			$('#newBsnsType').val('');
			$('#bsnsType').val('');
			$('#dptCde').val('');
			isDisable("empNo", true);
			$('input[onclick="openDeptDiv()"]').attr("disabled",true)
			isDisable("searchDeptBtn", true);
			isDisable("empName", true);
			isDisable("teamCode", true);
			isDisable("teamName", true);
			isDisable("agentNo", true);
			isDisable("agentName", true);
			isDisable("protocolNo", true);
			isDisable("serviceCode", true);
			isDisable("serviceName", true)
			$('#cRate').html('手续费比例上限：');
			$('#mRate').html('市场维护费比例上限：');
			$('#bRate').html('业务绩效比例上限：');
			$('#agentType601').hide();
			isDisable("commRate", false);
			isDisable("marketPreserveRate", false);
			isDisable("businessPerformanceRate", false);
			$("tr[id^=quDao0]").css('display','none');
			$("tr[id^=agentType1]").css('display','');
			$("tr[id^=agentType6]").css('display','none');
		}else if('4'!=agentType){
			isDisable("empNo", false);
			isDisable("empName", false);
			isDisable("teamCode", false);
			isDisable("teamName", false);
			isDisable("agentNo", false);
			isDisable("agentName", false);
			isDisable("protocolNo", false)
			isDisable("serviceCode", false)
			isDisable("serviceName", false)
			$('input[onclick="openDeptDiv()"]').attr("disabled",false)
			$("tr[id^=quDao0]").css('display','');
			$('#cRate').html('手续费比例：');
			$('#mRate').html('市场维护费比例：');
			$('#bRate').html('业务绩效比例：');
			$('#commRate').val('');
			$('#marketPreserveRate').val('');
			$('#businessPerformanceRate').val('');
			if('2'==agentFeeConfig){
				inputBtn();
				$("tr[id^=quDao0]").css('display','none');
				$('#empNo').val('');
				$('#empName').val('');
				$('#teamName').val('');
				$('#teamCode').val('');
				$('#agentNo').val('');
				$('#agentName').val('');
				$('#protocolNo').val('');
				$('#serviceCode').val('');
				$('#serviceName').val('');
				$('#channleCode_QD').val('');
				$('#channleType').val('');
				$('#newBsnsType').val('');
				$('#bsnsType').val('');
				$('#dptCde').val('');
				isDisable("empNo", true);
				$('input[onclick="openDeptDiv()"]').attr("disabled",true)
				isDisable("searchDeptBtn", true);
				isDisable("empName", true);
				isDisable("teamCode", true);
				isDisable("teamName", true);
				isDisable("agentNo", true);
				isDisable("agentName", true);
				isDisable("protocolNo", true);
				isDisable("serviceCode", true);
				isDisable("serviceName", true)
				$('#agentType601').show();
				isDisable("commRate", true);
				isDisable("marketPreserveRate", true);
				isDisable("businessPerformanceRate", true);
			}else{
				$("tr[id^=agentType6]").css('display','none');
				$("#quDao01").css('display','none');
				$("#quDao02").css('display','none');
				isDisable("commRate", false);
				isDisable("marketPreserveRate", false);
				isDisable("businessPerformanceRate", false);
				$('#agentType601').hide();
			}
		}
	}
	/**代理类型改变**/
	function agentChange(){
		var agentType=$('#agentType').val();
		if($('#isThirdPlan').val()!='1'&&agentType=='6'){
			$('#agentType').val('1');
			if($("#partnerNo").val()==""){
				$.message('error',"请先选中合作伙伴");
			}else{
				$.message('error',"此合作伙伴不支持接口传入方案");
			}
			agentChange();
			return;
		}
		$('#unionType').hide();
		var dptCode=$("#dptCde").val()
		$('#agentFeeConfig').val('');
		isDisable("empNo", false);
		isDisable("empName", false);
		isDisable("teamCode", false);
		isDisable("teamName", false);
		isDisable("agentNo", false);
		isDisable("agentName", false);
		isDisable("protocolNo", false)
		$('input[onclick="openDeptDiv()"]').attr("disabled",false)
		isDisable("serviceCode", false)
		isDisable("serviceName", false)
		isDisable("commRate", false);
		isDisable("marketPreserveRate", false);
		isDisable("businessPerformanceRate", false);
		$('#cRate').html('手续费比例：');
		$('#mRate').html('市场维护费比例：');
		$('#bRate').html('业务绩效比例：');
		isDisable("searchDeptBtn", false);
		$("tr[id^=agentType1]").css('display','none');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("tr[id^=agentType5]").css('display','none');
		$("tr[id^=agentType6]").css('display','none');
		$("tr[id^=agentType7]").css('display','none');
		$('#sale1').hide();
		$('#sale2').hide();
		//1、合作伙伴代理3、个人代理4、总对总代理7.激活卡代理
		if('1'==agentType){
			$("#cardApplicant_div").css('display','');
			$("#cardApplicant_div_cue").css('display','');
			$("#cardApplicant_title").css('display','');
			$("tr[id^=quDao0]").css('display','');
			$("tr[id^=agentType1]").css('display','');
			$("#commRateSpan").empty();
			$("#deptCode101").empty();
			$("#deptCode102").empty();
			$("#deptCode101").append("出单机构：");
			$("#deptCode102").append("<input id='dptCde' readonly='readonly' style='background-color: #ccc;' class='input_text' value='"+dptCode+"'><span class='red'>*</span>&nbsp;&nbsp;<input type='button'  class='input_button_2' value='请选择' onClick='openDeptDiv()' />");
		}else if('3'==agentType){}else if('4'==agentType){}else if('5'==agentType){}else if('6'==agentType){}
		else if('7'==agentType){}else if('8'==agentType){}else{}
		if('6'==agentType || '4'==agentType || '5'==agentType || '8'==agentType){}else{}
		if('5' == agentType && 'CYLH' == $('#unionType').val()){}else{}
	}
	/**是否可以录入*/
	function isDisable (obj,flag){
		//可用
		if(!flag){
			$("#"+obj).attr("disabled",false);
			$("#"+obj).css({"background-color": ""});
		}else{
			//不可用
			$("#"+obj).attr("disabled",true);
			$("#"+obj).css({"background-color": "#ccc"});
		}
	}
	//关闭 选择产品 弹出层
	function closeNlifeProdDiv(){
		$("#nlifeProdDiv").CloseDiv();
		$('#prodCode_choose').val("");
		$('#prodName_choose').val("");
		$('#startDateBegin').val("");
		$('#startDateEnd').val("");
	}

	//点击"请选择(合作伙伴)" 弹出合作伙伴选择层
	function openChannelInfoDiv(){
		//必须先选择产品，在选择合作伙伴
		if(($.trim($('#prodCode').val())).length==0){
			$.message('error',"请先选择产品");
			return;
		}

		//加载第一页合作伙伴信息
		queryChannelInfo(1);
	}

	//加载合作伙伴信息前，拼接参数
	function queryChannelInfo(pageIndex){
		var size = 8;
		var channelCode = $.trim($('#channelCode_choose').val());
		var channelName = $.trim($('#channelName_choose').val());

		loadChannelInfo({size:size,current:pageIndex,channelCode:channelCode,channelName:channelName});
	}

	//根据传入的参数，加载相应的合作伙伴
	function loadChannelInfo(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryChannelInfoPageByCriteria1?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;

				var radioObj ="<input class='input_fxk' name='radioChannelInfo' type='radio' value=''>";
				var fieldNames = "channelCode,channelName,deptCode@TDH,thirdPlan@TDH,channelFlag@TDH";
				var tableContent = creatTable1(fieldNames,page,radioObj);
				var tableObj = $("#channelInfoTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage2(param.current,6,page.maxPage,"42");
				var pageDIV = $("#channelInfoPageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);

				$('#channelInfoDiv').OpenDiv();

				bindradio();
			}
		});
	}

	/**网销专属方案处理*/
	function channelChannel(flag){
		if(flag=='1'){
			$('span[name="wxflag"]').hide()
			$('#state').removeAttr("disabled");
			$('#state').css({"background-color": ""});
			$('#isPushedSalesInfo1').show();
			$('#isPushedSalesInfo2').show();
		}else{
			$('span[name="wxflag"]').show();
			$("#state").attr("disabled","disabled");
			$('#state').css({"background-color": "#ccc"});
			$('#isPushedSalesInfo1').hide();
			$('#isPushedSalesInfo2').hide();
		}
	}

	//点击“确定”按钮，选择合作伙伴
	function chooseChannelInfo(){
		var partnerNo = $.trim($("#partnerNo").val());

		var selected = $("input[name='radioChannelInfo']:checked");
		if(selected.length==0){
			$.message("error", "请选择一个合作伙伴");
			return;
		}
		var channelCode = selected.parent().parent().children("td:eq(1)").html();
		var deptCode = selected.parent().parent().children("td:eq(3)").html();
		var thirdPlan = selected.parent().parent().children("td:eq(4)").html();
		var falg = selected.parent().parent().children("td:eq(5)").html();
		channelChannel(falg)
		channelFlag=falg;
		var dptCde=$.trim($("#dptCde").val());
		$('#partnerNo').val(channelCode);
		$('#isThirdPlan').val(thirdPlan);
		//合作伙伴 改变，同步改变 出单机构等
		if(partnerNo != channelCode){


			//代理信息
			$("#agentInfoRela3Table").find("tbody").remove();
			$("#agentInfoRela3PageDIV").innerHTML="";
			$("#agentInfoRela7Table").find("tbody").remove();
			$("#agentInfoRela7PageDIV").innerHTML="";
			$("#agentInfoRela4Table").find("tbody").remove();
			$("#agentInfoRela4PageDIV").innerHTML="";
			if(iscopy !=true){
				mapBak.clear();
				map.clear();
			}
		}
		closeChannelInfoDiv();
		//清空出单机构
		if((dptCde.length>0 && dptCde.substring(0,2)!=deptCode)){
			$("#dptCde").val("");
			$('#sale1').hide();
			$('#sale2').hide();
		}
	}

	//关闭 选择合作伙伴 弹出层
	function closeChannelInfoDiv(){
		$("#channelInfoDiv").CloseDiv();

		$('#channelCode_choose').val("");
		$('#channelName_choose').val("");
	}

	//点击"请选择(出单机构)" 弹出出单机构选择层
	function openDeptDiv(){
		//必须先选择合作伙伴，在选择出单机构
		if(($.trim($('#partnerNo').val())).length==0){
			$.message('error',"请先选择合作伙伴代码");
			return;
		}

		//加载第一页出单机构
		queryDept(1);
	}
	//定义deptFlag 当为1时 ，存的是出单机构，为2时存的是归属机构
	
	var deptFlag ;
	
	function openDeptDiv(flag){
		//必须先选择合作伙伴，在选择出单机构
		deptFlag = flag;

		if(($.trim($('#partnerNo').val())).length==0){
			$.message('error',"请先选择合作伙伴代码");
			return;
		}

		//加载第一页出单机构
		queryDept(1);
	}
	//加载出单机构信息前，拼接参数
	function queryDept(pageIndex){
		var size = 8;
		var partnerNo = $.trim($('#partnerNo').val());
		var deptCode = $.trim($('#deptCode_choose').val());
		var deptCname = $.trim($('#deptCname_choose').val());

		loadDept({size:size,current:pageIndex,deptCode:deptCode,deptCname:deptCname,partnerNo:partnerNo});
	}

	//根据传入的参数，加载相应的出单机构
	function loadDept(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryDeptPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;

				var radioObj ="<input class='input_fxk' name='radioDept' type='radio'/>";
				var fieldNames = "deptCode,deptCNname";
				var tableContent = creatTable1(fieldNames,page,radioObj);
				var tableObj = $("#deptTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage3(param.current,6,page.maxPage,"44");
				var pageDIV = $("#deptPageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				$('#deptDiv').OpenDiv();
				bindradio();
			}
		});
	}

	//点击“确定”按钮，选择出单机构
	function chooseDept(){
		var dptCde_current ;
		var regressDept_current ;
		if(deptFlag == "1"){
			dptCde_current = $.trim($('#dptCde').val());	
		}else {
			regressDept_current = $.trim($('#dptCde').val());
		}
		
		
		var selected = $("input[name='radioDept']:checked");
		if(selected.length==0){
			$.message("error", "请选择一个出单机构");
			return;
		}
		var choosedVal = selected.parent().parent().children(" td:eq(1)").html();
		
		if(deptFlag =='1'){
			$('#dptCde').val(choosedVal);
		}else {
			$('#regressDept').val(choosedVal);
		}
		closeDeptDiv();
	}

	//关闭 选择出单机构 弹出层
	function closeDeptDiv(){
		$("#deptDiv").CloseDiv();

		$('#deptCode_choose').val("");
		$('#deptCname_choose').val("");
	}

	//绑定单选按钮事件，选中某个单选按钮，该按钮所在行高亮显示
	function bindradio(){
		$("input[name='radioNlifeProd']").click(function(){
			$("input[name='radioNlifeProd']").parent().parent().removeClass("table_highlighter");
			$(this).parent().parent().addClass("table_highlighter");
		});
		$("input[name='radioChannelInfo']").click(function(){
			$("input[name='radioChannelInfo']").parent().parent().removeClass("table_highlighter");
			$(this).parent().parent().addClass("table_highlighter");
		});
		$("input[name='radioDept']").click(function(){
			$("input[name='radioDept']").parent().parent().removeClass("table_highlighter");
			$(this).parent().parent().addClass("table_highlighter");
		});
		$("input[name='agentInfo6radioBox']").click(function(){
			$("input[name='agentInfo6radioBox']").parent().parent().removeClass("table_highlighter");
			$(this).parent().parent().addClass("table_highlighter");
		});
		$("input[name='agentInfo3checkbox']").click(function(){
			var id= $(this).parent().parent().children("td:eq(1)").html();
			if($(this).prop("checked")){//选中
				$(this).parent().parent().addClass("table_highlighter");
				var obj = new Object();
				var cardApplicant= $(this).parent().parent().children("td:eq(7)").html();
				var commRate_Div= $(this).parent().parent().find("input[name='commRate_Div']").val();
				var market=$(this).parent().parent().find("input[name='marketRate_Div']").val();
				var business=$(this).parent().parent().find("input[name='businessRate_Div']").val();
				obj.id =id;
				obj.cardapplicant = cardApplicant;
				obj.commrate= commRate_Div;
				obj.market=market;
				obj.business=business;
				map.put(obj.id,obj);
			}else{//取消选中
				$(this).parent().parent().removeClass("table_highlighter");
				$(this).prop("checked",false);
				map.remove(id);
			}
		});
		$("input[name='agentInfo7checkbox']").click(function(){
			var id= $(this).parent().parent().children("td:eq(1)").html();
			if($(this).prop("checked")){//选中
				$(this).parent().parent().addClass("table_highlighter");
				var obj = new Object();
				var cardApplicant= $(this).parent().parent().children("td:eq(7)").html();
				var commRate_Div= $(this).parent().parent().find("input[name='commRate_Div']").val();
				var market=$(this).parent().parent().find("input[name='marketRate_Div']").val();
				var business=$(this).parent().parent().find("input[name='businessRate_Div']").val();
				obj.id =id;
				obj.cardapplicant = cardApplicant;
				obj.commrate= commRate_Div;
				obj.market=market;
				obj.business=business;
				map.put(obj.id,obj);
			}else{//取消选中
				$(this).parent().parent().removeClass("table_highlighter");
				$(this).prop("checked",false);
				map.remove(id);
			}
		});
		$("#agentInfo3CheckAll").click(function(){
			if($(this).prop("checked")){//选中
				$("#agentInfo3Table tbody tr").each(function() {
					$(this).find("input[name='agentInfo3checkbox']").prop("checked",true);
					$(this).addClass("table_highlighter");
					var obj = new Object();
					obj.id = $(this).children("td:eq(1)").html();
					obj.cardapplicant = $(this).children("td:eq(9)").html();
					obj.commrate = $(this).find("input[name='commRate_Div']").val();
					obj.market=$(this).find("input[name='marketRate_Div']").val();
					obj.business=$(this).parent().parent().find("input[name='businessRate_Div']").val();
					map.put(obj.id,obj);

				});
			}else{//取消选中
				$("#agentInfo3Table tbody tr").each(function() {
					$(this).removeClass("table_highlighter");
					$(this).find("input[name='agentInfo3checkbox']").prop("checked",false);
					var id= $(this).children("td:eq(1)").html();
					map.remove(id);
				});
			}
		});
		$("#agentInfo7CheckAll").click(function(){
			if($(this).prop("checked")){//选中
				$("#agentInfo7Table tbody tr").each(function() {
					$(this).find("input[name='agentInfo7checkbox']").prop("checked",true);
					$(this).addClass("table_highlighter");
					var obj = new Object();
					obj.id = $(this).children("td:eq(1)").html();
					obj.cardapplicant = $(this).children("td:eq(9)").html();
					obj.commrate = $(this).find("input[name='commRate_Div']").val();
					obj.market=$(this).find("input[name='marketRate_Div']").val();
					obj.business=$(this).parent().parent().find("input[name='businessRate_Div']").val();
					map.put(obj.id,obj);

				});
			}else{//取消选中
				$("#agentInfo7Table tbody tr").each(function() {
					$(this).removeClass("table_highlighter");
					$(this).find("input[name='agentInfo7checkbox']").prop("checked",false);
					var id= $(this).children("td:eq(1)").html();
					map.remove(id);
				});
			}
		});
		$("input[name='agentInfo4checkbox']").click(function(){
			var id= $(this).parent().parent().children("td:eq(1)").html();
			if($(this).prop("checked")){//选中
				$(this).parent().parent().addClass("table_highlighter");
				var obj = new Object();
				var columnes=$("#agentInfo4Table").find("th").length;
				if(columnes==17){
					obj.cardapplicant= $(this).parent().parent().children("td:eq(12)").html();
				}else if(columnes==19){
					obj.cardapplicant= $(this).parent().parent().children("td:eq(14)").html();
				}
				var commRate_Div= $(this).parent().parent().find("input[name='commRate_Div']").val();
				var market=$(this).parent().parent().find("input[name='marketRate_Div']").val();
				var business=$(this).parent().parent().find("input[name='businessRate_Div']").val();
				obj.id =id;
				obj.cardapplicant = cardApplicant;
				obj.commrate= commRate_Div;
				obj.market=market;
				obj.business=business;
				map.put(obj.id,obj);
			}else{//取消选中
				$(this).parent().parent().removeClass("table_highlighter");
				$(this).prop("checked",false);
				map.remove(id);
			}
		});
		$("input[name='agentInfoZon4checkbox']").click(function(){
			var branch= $(this).parent().parent().children(" td:eq(1)").html();
			if($(this).prop("checked")){//选中
				$(this).parent().parent().addClass("table_highlighter");
				var commRate= $(this).parent().parent().children("td:eq(7)").find('input').val();
				var marketRate= $(this).parent().parent().children(" td:eq(8)").find('input').val();
				var businessRate= $(this).parent().parent().children(" td:eq(9)").find('input').val();
				var o=new Object();
				o.commRate=commRate;
				o.marketRate=marketRate;
				o.businessRate=businessRate;
				o.branch=branch;
				zonMap.put(branch, o);
			}else{//取消选中
				$(this).parent().parent().removeClass("table_highlighter");
				$(this).prop("checked",false);
				zonMap.remove(branch);
			}
		});

		$("input[name='agentInfoZon5checkbox']").click(function(){
			var branch= $(this).parent().parent().children(" td:eq(1)").html();
			if($(this).prop("checked")){//选中
				$(this).parent().parent().addClass("table_highlighter");
				var commRate= $(this).parent().parent().children("td:eq(7)").find('input').val();
				var marketRate= $(this).parent().parent().children(" td:eq(8)").find('input').val();
				var businessRate= $(this).parent().parent().children(" td:eq(9)").find('input').val();
				var o=new Object();
				o.commRate=commRate;
				o.marketRate=marketRate;
				o.businessRate=businessRate;
				o.branch=branch;
				zonMap.put(branch, o);
			}else{//取消选中
				$(this).parent().parent().removeClass("table_highlighter");
				$(this).prop("checked",false);
				zonMap.remove(branch);
			}
		});

		$("#agentInfo4CheckAll").click(function(){
			if($(this).prop("checked")){//选中
				$("#agentInfo4Table tbody tr").each(function() {
					$(this).find("input[name='agentInfo4checkbox']").prop("checked",true);
					$(this).addClass("table_highlighter");
					var obj = new Object();
					obj.id = $(this).children("td:eq(1)").html();
					var columnes=$("#agentInfo4Table").find("th").length;
					if(columnes==15){
						obj.cardapplicant = $(this).children("td:eq(10)").html();
					}else if(columnes==17){
						obj.cardapplicant = $(this).children("td:eq(12)").html();
					}
					obj.commrate = $(this).find("input[name='commRate_Div']").val();
					obj.market=$(this).find("input[name='marketRate_Div']").val();
					obj.business=$(this).parent().parent().find("input[name='businessRate_Div']").val();
					map.put(obj.id,obj);
				});
			}else{//取消选中
				$("#agentInfo4Table tbody tr").each(function() {
					$(this).removeClass("table_highlighter");
					$(this).find("input[name='agentInfo4checkbox']").prop("checked",false);
					var id= $(this).children("td:eq(1)").html();
					map.remove(id);
				});
			}
		});

		$("input[name='agentInfo5checkbox']").click(function(){
			var id= $(this).parent().parent().children("td:eq(1)").html();
			if($(this).prop("checked")){//选中
				$(this).parent().parent().addClass("table_highlighter");
				var obj = new Object();
				obj.cardapplicant = $(this).children("td:eq(7)").html();
				var commRate_Div= $(this).parent().parent().find("input[name='commRate_Div']").val();
				var market=$(this).parent().parent().find("input[name='marketRate_Div']").val();
				var business=$(this).parent().parent().find("input[name='businessRate_Div']").val();
				obj.id =id;
				obj.cardapplicant = cardApplicant;
				obj.commrate= commRate_Div;
				obj.market=market;
				obj.business=business;
				map.put(obj.id,obj);
			}else{//取消选中
				$(this).parent().parent().removeClass("table_highlighter");
				$(this).prop("checked",false);
				map.remove(id);
			}
		});

		$("#agentInfo5CheckAll").click(function(){
			if($(this).prop("checked")){//选中
				$("#agentInfo5Table tbody tr").each(function() {
					$(this).find("input[name='agentInfo5checkbox']").prop("checked",true);
					$(this).addClass("table_highlighter");
					var obj = new Object();
					obj.id = $(this).children("td:eq(1)").html();
					obj.cardapplicant = $(this).children("td:eq(7)").html();
					obj.commrate = $(this).find("input[name='commRate_Div']").val();
					obj.market=$(this).find("input[name='marketRate_Div']").val();
					obj.business=$(this).parent().parent().find("input[name='businessRate_Div']").val();
					map.put(obj.id,obj);
				});
			}else{//取消选中
				$("#agentInfo5Table tbody tr").each(function() {
					$(this).removeClass("table_highlighter");
					$(this).find("input[name='agentInfo5checkbox']").prop("checked",false);
					var id= $(this).children("td:eq(1)").html();
					map.remove(id);
				});
			}
		});
	}
	function zonRateChange(obj){
		var rate=$(obj).attr("name");
		var branch= $(obj).parent().parent().children(" td:eq(1)").html();
		var o=zonMap.get(branch);
		if(o){
			//手续费比例
			if("commRate_Zon"==rate){
				o.commRate= $(obj).val()+"";
			}else if("marketRate_Zon"==rate){
				o.marketRate=$(obj).val()+"";;
			}else if("businessRate_Zon"==rate){
				o.businessRate=$(obj).val()+"";
			}
			zonMap.put(branch,o);
		}
	}
	var branchs='';
	//区域总对总保存
	function saveChosenZonAgentInfo4(){
		var riskType = $("#riskType").val();
		var isInternetRisk = $("#isInternetRisk").val();
		var risklimit = $("#riskToplimit").val();
		var planListStr ='';
		var planNo=$('#planNo').val();
		var partnerNo = $.trim($("#partnerNo").val());
		if(!zonMap.isEmpty()){
			var totalRate=0;
			var tradPlanlist = new Array();
			for(i in zonMap.keys()){
				var key = zonMap.keys()[i];
				var o=zonMap.get(key);
				var reg=/^0(\.\d{0,6})?$/;
				if( o.commRate!=""&&o.commRate!=null&&o.commRate!="null"){
					if(!reg.test(o.commRate)){
						$.message("error","手续费比例只能录入0到1之间的有效数字，分公司代码为"+key);
						return false;
					}
				}
				var reg=/^0(\.\d{0,6})?$/;
				if( o.marketRate!=""&&o.marketRate!=null&&o.marketRate!="null"){
					if(!reg.test(  o.marketRate)){
						$.message("error","市场维护费比例只能录入0到1之间的有效数字，分公司代码为"+key);
						return false;
					}
				}
				var reg=/^0(\.\d{0,6})?$/;
				if( o.businessRate!=""&&o.businessRate!=null&&o.businessRate!="null"){
					if(!reg.test( o.businessRate)){
						$.message("error","业务绩效比例只能录入0到1之间的有效数字，分公司代码为"+key);
						return false;
					}
				}
				if (o.commRate!=""&&o.commRate!=null&&o.marketRate!=""&&o.marketRate!=null&&o.businessRate!=""&&o.businessRate!=null&&risklimit!=null){
					var riskToplimit = parseFloat(risklimit).toFixed(6);
					//互联网专属
					if("Y" == isInternetRisk|| "y" == isInternetRisk){
						var allRate = (parseFloat(o.commRate) + parseFloat(o.commRate) + parseFloat(o.commRate)).toFixed(6);
						if(allRate > riskToplimit){
							$.message("error","手续费比例、市场维护费比例、业务绩效比例之和大于条款比例上限");
							return false;
						}
					} else{
						if(parseFloat(o.commRate).toFixed(6) > riskToplimit && "1" == riskType){
							$.message("error","手续费比例大于条款比例上限");
							return false;
						}
					}
				}
				totalRate=totalRateSum(o);
				if(totalRate>=1){
					$.message("error","三费之和必须小于1，机构代码为‘"+key+"’的超出");
					return false;
				}
				if(branchs==''){
					branchs=key;
				}else{
					branchs+=","+key;
				}
				tradPlanlist.push(zonMap.get(key));
			}
			planListStr=JSON.stringify(tradPlanlist);
		}else{
			$.message("error","请选择机构");
			return false;
		}
		updateZon4Config({zonListStr:planListStr,planNo:planNo,branchs:branchs,partnerNo:partnerNo})

	}
	//区域联合出单保存
	function saveChosenZonAgentInfo5(){
		var riskType = $("#riskType").val();
		var isInternetRisk = $("#isInternetRisk").val();
		var risklimit = $("#riskToplimit").val();
		var planListStr ='';
		var planNo=$('#planNo').val();
		var partnerNo = $.trim($("#partnerNo").val());
		if(!zonMap.isEmpty()){
			var totalRate=0;
			var tradPlanlist = new Array();
			for(i in zonMap.keys()){
				var key = zonMap.keys()[i];
				var o=zonMap.get(key);
				var reg=/^0(\.\d{0,6})?$/;
				if( o.commRate!=""&&o.commRate!=null&&o.commRate!="null"){
					if(!reg.test(o.commRate)){
						$.message("error","手续费比例只能录入0到1之间的有效数字，分公司代码为"+key);
						return false;
					}
				}
				var reg=/^0(\.\d{0,6})?$/;
				if( o.marketRate!=""&&o.marketRate!=null&&o.marketRate!="null"){
					if(!reg.test(  o.marketRate)){
						$.message("error","市场维护费比例只能录入0到1之间的有效数字，分公司代码为"+key);
						return false;
					}
				}
				var reg=/^0(\.\d{0,6})?$/;
				if( o.businessRate!=""&&o.businessRate!=null&&o.businessRate!="null"){
					if(!reg.test( o.businessRate)){
						$.message("error","业务绩效比例只能录入0到1之间的有效数字，分公司代码为"+key);
						return false;
					}
				}
				if (o.commRate!=""&&o.commRate!=null&&o.marketRate!=""&&o.marketRate!=null&&o.businessRate!=""&&o.businessRate!=null&&risklimit!=null){
					var riskToplimit = parseFloat(risklimit).toFixed(6);
					//互联网专属
					if("Y" == isInternetRisk || "y" == isInternetRisk){
						var allRate = (parseFloat(o.commRate) + parseFloat(o.commRate) + parseFloat(o.commRate)).toFixed(6);
						if(allRate > riskToplimit){
							$.message("error","手续费比例、市场维护费比例、业务绩效比例之和大于条款比例上限");
							return false;
						}
					} else{
						if(parseFloat(o.commRate).toFixed(6) > riskToplimit && "1" == riskType){
							$.message("error","手续费比例大于条款比例上限");
							return false;
						}
					}
				}
				totalRate=totalRateSum(o);
				if(totalRate>=1){
					$.message("error","三费之和必须小于1，机构代码为‘"+key+"’的超出");
					return false;
				}
				if(branchs==''){
					branchs=key;
				}else{
					branchs+=","+key;
				}
				tradPlanlist.push(zonMap.get(key));
			}
			planListStr=JSON.stringify(tradPlanlist);
		}else{
			$.message("error","请选择机构");
			return false;
		}
		updateZon5Config({zonListStr:planListStr,planNo:planNo,branchs:branchs,partnerNo:partnerNo})

	}
	/**三费和**/
	function totalRateSum(obj){
		var totalRate=0;
		if(obj.commRate!=''&&obj.commRate!=null&&obj.commRate!='null'){
			totalRate=totalRate+parseFloat(obj.commRate);
		}
		if(obj.marketRate!=''&&obj.marketRate!=null&&obj.marketRate!='null'){
			totalRate=totalRate+parseFloat(obj.marketRate);
		}
		if(obj.businessRate!=''&&obj.businessRate!=null&&obj.businessRate!='null'){
			totalRate=totalRate+parseFloat(obj.businessRate);
		}
		return totalRate;
	}
	//总对总删除
	function clearAgentInfoZon4Div(){
		var planNo=$('#planNo').val();
		var partnerNo = $.trim($("#partnerNo").val());
		$.dialog({
			type: "warn",
			content: "是否清除销售信息，重新配置？",
			onOk: function() {
				$.openLoading();
				$.ajax({
					url : "<%=path%>/nlifePlanConfig/clearAgentInfoZon4Div?"+new Date().getTime(),
					type: "POST",
					async:true,
					data:{
						planNo:planNo,
						partnerNo:partnerNo
					},
					dataType: "json",
					success: function(result) {
						$.closeLoading();
						$.message(result.result,result.message);
						if(result.result=='success'){
							setTimeout(function(){
								window.location.reload();
							},500);
						}
						queryAgentInfoRela4(1);
					}
				});
			}
		});
	}//总对总删除结束
	//区域总对总保存
	function updateZon4Config(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/updateZon4Config",
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(result){
				$.closeLoading();
				$.message(result.result,result.message);
				if(result.result=="success"){
					setTimeout(function(){
						closeAgentInfoDiv('agentInfoZon4Div');
						window.location.reload();
					},500);
				}
			}
		});
	}
	//区域联合出单保存
	function updateZon5Config(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/updateZon5Config",
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(result){
				$.closeLoading();
				$.message(result.result,result.message);
				if(result.result=="success"){
					setTimeout(function(){
						closeAgentInfoDiv('agentInfoZon5Div');
						window.location.reload();
					},500);
				}
			}
		});
	}
	//联合出单删除
	function clearAgentInfoZon5Div(){
		var planNo=$('#planNo').val();
		var partnerNo = $.trim($("#partnerNo").val());
		$.dialog({
			type: "warn",
			content: "是否清除销售信息，重新配置？",
			onOk: function() {
				$.openLoading();
				$.ajax({
					url : "<%=path%>/nlifePlanConfig/clearAgentInfoZon5Div?"+new Date().getTime(),
					type: "POST",
					async:true,
					data:{
						planNo:planNo,
						partnerNo:partnerNo
					},
					dataType: "json",
					success: function(result) {
						$.closeLoading();
						$.message(result.result,result.message);
						if(result.result=='success'){
							setTimeout(function(){
								window.location.reload();
							},500);
						}
						queryAgentInfoRela5(1);
					}
				});
			}
		});
	}
	/**电子保单模板查询*/
	function emailTemplate(){
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryEmailTempList?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{},
			dataType:'json',
			success:function(data){
				var templates=data.templates;
				if(templates){
					for (var i = 0; i < templates.length; i++) {
						emailMap.put(templates[i].selKey,templates[i].emailTemplate);
					}
				}

			}
		});
	}
	/**电子邮件模板值处理**/
	function setEmailTemplate(flag){
		if(flag=='1'){
			return;
		}
		var selKey='';
		var DownloadWay=$("#DownloadWay").val();
		var fileType=$("#fileType").val();
		var isInsuranceEinvoice = $("#isInsuranceEinvoice").val();
		if(isInsuranceEinvoice=='N'){
			// 选择不即时开票 ，等同于不要发票（邮件模板中不带发票连接）
			isEpolicyInvoice = '2';
		}
		selKey=selKey+'-'+isEpolicyInvoice;
		var selectAccessorys=$('input[name=SendAccessoryBox]').get(0);
		if(selectAccessorys.checked){
			selKey=selKey+'-'+'Y';
		}else{
			selKey=selKey+'-';
		}
		if(emailMap.get(selKey)){
			var emailTemplate = emailMap.get(selKey);
			$('#MailTemplate').val(emailTemplate);
		}else{
			$('#MailTemplate').val('');
		}
	}
	//电子邮件改变时
	function CheckedSendMail(){
		var ChecdedMail=$("#isEpolicyMali").val();
		if(ChecdedMail==1){
			$("#MailTemplateTr").show();
			$('#MailTemplate').html("");
			$("#sendAccessory").show();
			$("#sendAccessoryTd").show();
			$('#SendAccessoryBox').show();
			$('input[name=SendAccessoryBox]').attr('disabled',false);
			setEmailTemplate();
		}else{
			$("#MailTemplateTr").hide();
			$("#sendAccessory").show();
			$("#sendAccessoryTd").show();
			$('input[name=SendAccessoryBox]').attr("checked", false);
			$('input[name=SendAccessoryBox]').attr('disabled',true);
		}
	}
	//是否回执
	function chooseReceiptType(){
		var value = $('#isReceipt').val();
		var receiptType = $('#receiptType').val();
		if('Y' == value){
			$('#isOrNotDisplayReceiptTypeDiv').show();
			$('#receiptType').val('01');
		}else if('N' == value){
			$('#isOrNotDisplayReceiptTypeDiv').hide();
		}
	}
	//是否分期
	function choosePaymentType(){
		var value = $('#isPayment').val();
		var paymentType = $('#paymentType').val();
		if('Y' == value){
			$('#isOrNotDisplayPaymentTypeDiv').show();
			$('#paymentType').val('01');

		}else if('N' == value){
			$('#isOrNotDisplayPaymentTypeDiv').hide();
		}
	}
	function isSendPolicyChange(obj){
		if($(obj).val()=='01'){
			/**查看是否选中了电子保单*/
			var isEpolicy =$("#isEpolicy").val();
			if(obj.checked&&'N'==isEpolicy){
				$.message('error',"是否电子保单为否，附件不能发送电子保单");
				obj.checked=false;
				return;
			}
			setEmailTemplate();
		}
	}
	//是否电子保单
	function IsEpolicyChange(){
		//判断是否已配置电子保单模板
		var iseplicyFlag=$("#iseplicyFlag").val();
		if($("#prodCode").val()==''){
			$.message('error',"请先选中产品");
			return;
		}
		var IsEpolicy =$.trim($('#isEpolicy').val());
		if(iseplicyFlag=='-'){
			iseplicyFlag='';
		}
		$('#propTitle').html("保单模板："+iseplicyFlag);
		var Download_right=$('#Download_right');
		var isEpolicyMali =$('#isEpolicyMali').val();
		if(isEpolicyMali=='1'){
			setEmailTemplate();
		}
	}
	//“保存”按钮（添加/编辑方案）
	function checkAndExcute(flag){
		saveRiskInfo();
		var planNo = $.trim($('#planNo').val());
		var planName = $.trim($('#planName').val());
		/**是否上线产品*/
		var isProprod=false;
		if($("#isProprod").is(':checked')){
			isProprod=true;
		}
		if(planName.length==0){
			$.message("error", "请输入投保方案名称");
			$('#planName').focus();
			return;
		}
		var prodCode = $.trim($('#prodCode').val());
		if(prodCode.length==0){
			$.message("error", "请选择产品编号");
			$('#prodCode').focus();
			return;
		}
		var partnerNo = $.trim($('#partnerNo').val());
		if(partnerNo.length==0){
			$.message("error", "请选择合作伙伴代码");
			$('#partnerNo').focus();
			return;
		}

		var channleCode_QD = $.trim($('#channleCode_QD').val());
		var channleType = $.trim($('#channleType').val());
		var newBsnsType = $.trim($('#newBsnsType').val());
		var categoryCode = $.trim($('#bsnsType').val());
		var agentType= $.trim($("#agentType").val());
		//1、合作伙伴代理3、个人代理4、总对总代理
		var dptCde = $.trim($('#dptCde').val());
		if(agentType == "1"&&channelFlag!='1'){
<%--			if(channleCode_QD.length==0){--%>
<%--				$.message("error", "请选择归属渠道");--%>
<%--				$('#channleCode_QD').focus();--%>
<%--				return;--%>
<%--			}--%>
<%--			if(channleType.length==0){--%>
<%--				$.message("error", "请选择渠道类型");--%>
<%--				$('#channleType').focus();--%>
<%--				return;--%>
<%--			}--%>
<%--			if(newBsnsType.length==0){--%>
<%--				$.message("error", "请选择新业务来源");--%>
<%--				$('#newBsnsType').focus();--%>
<%--				return;--%>
<%--			}--%>
<%--			if(categoryCode.length==0){--%>
<%--				$.message("error", "请选择原业务来源");--%>
<%--				$('#bsnsType').focus();--%>
<%--				return;--%>
<%--			}--%>
			if(dptCde.length==0){
				$.message("error", "请选择出单机构");
				$('#dptCde').focus();
				return;
			}
		}

		var commRate = $.trim($('#commRate').val());
		var marketPreserveRate = $.trim($('#marketPreserveRate').val());
		var businessPerformanceRate = $.trim($('#businessPerformanceRate').val());
		var agentFeeConfig=$('#agentFeeConfig').val();
		//联合出单车加意新增车加意特约
		var carAccidentSpecial = $.trim($('#carAccidentSpecial').val());
		var unionType='';
		if(agentType=='5'|| agentType=='8'){
			unionType=$('#unionType').val();
			if(unionType==''){
				$.message("error","请选择联合出单方案");
				return;
			}
		}
		if($('#isThirdPlan').val()!='1'&&agentType=='6'&&flag!='update'){
			$.message('error',"此合作伙伴不支持接口传入方案");
			return;
		}
		//接口传入方案结束
		//1、合作伙伴代理3、个人代理4、总对总代理
		var empNo = $.trim($('#empNo').val());
		var empName = $.trim($('#empName').val());
		var teamCode = $.trim($('#teamCode').val());
		var teamName = $.trim($('#teamName').val());

//		var categoryCode = $.trim($("#newBsnsType").find("option:selected").attr("categoryCode"));
		var agentNo = $.trim($('#agentNo').val());
		var agentName = $.trim($('#agentName').val());
		var protocolNo = $.trim($('#protocolNo').val());
		var serviceCode = $.trim($('#serviceCode').val());
		var serviceName = $.trim($('#serviceName').val());
		//var state = $.trim($('#state').val());
		var state = '1';
		var checkStatus = "已审核";
		//是否电子保单
		var isEpolicy_val = $.trim($('#isEpolicy').val());
		var DownloadWay_val='';
		var fileType='';
		var isSeeMoney = $.trim($('#isSeeMoney').val());
		var messageReceiver_val = $('#messageReceiver').val();
		//是否回执
		var isReceipt = $.trim($('#isReceipt').val()); //2015年6月1日11:56:40 wangyan add
		var receiptType = $('#receiptType').val();
		if('Y'== isReceipt){
			if($('#receiptType').val() == ""){
				$.message("error", "请选择回执类型");
				return;
			}
		}else if('N'== isReceipt){
			receiptType="";
		}
		//是否分期
		var isPayment = $.trim($('#isPayment').val());
		var paymentType = $('#paymentType').val();
		if('Y'== isPayment){
			if($('#paymentType').val() == ""){
				$.message("error", "请选择分期类型");
				return;
			}
		}else if('N'== isPayment){
			paymentType="";
		}
		var dentification=$('#dentification').val();
		//是否开通支付平台
		//var isDredgePay=$.trim($('#isDredgePay').val());
		//是否见费出单
		var isSeeMoney = $.trim($('#isSeeMoney').val());
		//if(isDredgePay==''){
		//	$.message('error',"请选择是否开通支付平台");
		//return;
		//}
		//if(isSeeMoney=="N"){
		//	isDredgePay="";
		//}

		//是否发送邮件
		var isEpolicyMali=$.trim($('#isEpolicyMali').val());
		//邮件模板
		var MailTemplate=$.trim($('#MailTemplate').val());
		//转码，可能会传入html的数据
		if(MailTemplate!=null){
			MailTemplate=encodeURI(MailTemplate);
		}
		//获取附加数组
		var selectAccessorys=$('input[name=SendAccessoryBox]:checked');
		//定义一个转换后的字符串
		var selectAccessorylistStr='';
		//判断数组长度
		if(selectAccessorys.length!=0){
			//循环添加
			selectAccessorys.each(function(i){
				var object=new Object();
				object.id=$(this).val();
				map1.put(object.id,object);
			});
		}
		//判断map是否为空
		if(!map1.isEmpty()){
			//定义list
			var selectAccessorylist =new  Array();
			//循环k值
			for(i in map1.keys()){
				//得到key
				var key=map1.keys()[i];
				//得到值
				selectAccessorylist.push(map1.get(key));
			}
			//转换成字符串
			selectAccessorylistStr=JSON.stringify(selectAccessorylist);
		}

		var specialArran = $.trim($('#specialArran').val());
		var notice =$.trim($('#notice').val());
		var checkOpinion =$.trim($('#checkOpinion').val());
		var arr='';
		var arr1 = new Array();
		if(flag!="update"){
			var sale=dptCde.substring(0,2);
			if(sale=='44'){
				for (var i = 1; i <= 5; i++) {
					if(salemap.get(i)){
						arr1.push(salemap.get(i));
					}
				}
				arr=JSON.stringify(arr1);
			}
		}
		//争议解决方式
		var dicputeType=$.trim($('#dicputeType').val());
		var arbitrationDept=$.trim($('#arbitrationDept').val());
		if(dicputeType!='2'){
			arbitrationDept="";
			$("#arbitrationDept").hide();
		}
		//是否发送体检短信
		var isMedicalMessage=$('#isMedicalMessage').val();
		//注销短信
		var isCancelMessage=$('#isCancelMessage').val();
		var cancelReceiver= $.trim($('#cancelReceiver').val());
		var cancelTemplate_val= $.trim($('#cancelTemplate').val());
		var cancelTemplate = $('#isCancelTemplate').val();
		if(cancelTemplate_val!=null){
			cancelTemplate_val=encodeURI(cancelTemplate_val);
		}
		if(isCancelMessage=="Y"){
			if(cancelReceiver.length==0){
				$.message("error", "请选择注销短信接收人");
				return;
			}
			if(cancelTemplate_val.length==0){
				$.message("error", "注销短信模板配置不能为空");
				return;
			}
		}else{
			cancelTemplate='';
			cancelReceiver='';
		}
		if('1'==agentType&&salemap.isEmpty()&&dptCde.substring(0,2)=='44'){
			$.message("error", "此方案需要配置广东销售信息");
			return;
		}
		//续保费用比利差值
		var rateSubtract = $.trim($('#rateSubtract').val());
		if(rateSubtract < 0 || rateSubtract >= 1){
			$.message("error","续保费用差值比例:只能录入0-1之间的有效数字(最多六位小数)");
			return ;
		}
		if(isNaN(rateSubtract)){
			$.message("error","续保费用比例差值必须为数字");
			return ;
		}

		//是否需进行风险查询
		var isRiskQuery = $('#isRiskQuery').val();
		//是否后付费
		var isAfterPay = $('#isAfterPay').val();
		//是否增值服务
		var isAddedService = $('#isAddedService').val();
		//增值服务代码
		var addedServiceCode = $('#addedServiceCode').val();
		//增值服务名称
		var addedServiceName = $('#addedServiceName').val();
		//增值服务次数
		var addedServiceCount = $('#addedServiceCount').val();
		//增值服务类别
		var serviceType = $('#serviceTypeSelect').val();
		var businessNature3 = $('#businessNature3').val();
		var greenIndustryFirst = $('#greenIndustryFirst').val();
		var greenIndustrySecond = $('#greenIndustrySecond').val();
		var businessNature1 = $('#businessNature1').val();
		var businessNature2 = $('#businessNature2').val();
		var txChannel = $('#txChannel2nd').val();
		var tkFlag = $('#tkFlag').val();
		var einvoiceType = $('#einvoiceType').val();
		var operatorNo = $('#operatorNo').val();
		var regressDept = $('#regressDept').val();
		var otherRate = $('#otherRate').val();
		var isEInvoice = $('#isEInvoice').val();
		if(isEInvoice == 'N'){
			einvoiceType = "";
		}
		if("Y" == isAddedService){
			if("" == addedServiceCode || null == addedServiceCode){
				$.message("error", "请填写增值服务代码");
				return;
			}
			if("" == addedServiceName || null == addedServiceCode){
				$.message("error", "请填写增值服务名称");
				return;
			}
			if("" == addedServiceCount || null == addedServiceCode){
				$.message("error", "请填写增值服务次数");
				return;
			}
			if("" == serviceType || null == serviceType){
				$.message("error", "请选择增值服务类型");
				return;
			}

		}else {
			addedServiceCode = '';
			addedServiceName = '';
			addedServiceCount = '';
			serviceType = '';
		}
		var mfacadeIsReInsure = $('#mfacadeIsReInsure').val();
        var isPushedSalesInfo = $('#isPushedSalesInfo').val();
        //元保升级产品特约取值
        var updateSpecialArranList = $('textarea[name="updateSpecialArran"]');
        var updateSpecialArran = "";
        if(updateSpecialArranList!= null && updateSpecialArranList.length >0){
        	//有升级特约
       		for(var i = 0; i < updateSpecialArranList.length ; i++){
				updateSpecialArran += updateSpecialArranList[i].id + "=" +  updateSpecialArranList[i].value + ";";
        	}
        }
		if(flag=="add"){
			excuteAdd({fileType:fileType,isCancelMessage:isCancelMessage,cancelReceiver:cancelReceiver,cancelTemplate:cancelTemplate,
				dicputeType:dicputeType,arbitrationDept:arbitrationDept,planType:'3',
				saleArry:arr,planName:planName,prodCode:prodCode,partnerNo:partnerNo,channleCode:channleCode_QD,channleType:channleType,
				newBsnsType:newBsnsType,categoryCode:categoryCode,dptCde:dptCde,commRate:commRate,empNo:empNo,empName:empName,
				teamCode:teamCode,teamName:teamName,agentNo:agentNo,agentName:agentName,protocolNo:protocolNo,serviceCode:serviceCode,serviceName:serviceName,
				state:state,isEpolicy:isEpolicy_val,isSeeMoney:isSeeMoney,isReceipt:isReceipt,
				specialArran:specialArran,notice:notice,
				isSendEmail:isEpolicyMali,emailTemplate:MailTemplate,
				epolicyDownloadWay:DownloadWay_val,receiptType:receiptType,selAccessory:selectAccessorylistStr,marketPreserveRate:marketPreserveRate,
				businessPerformanceRate:businessPerformanceRate,checkOpinion:checkOpinion,checkStatus:checkStatus,agentFeeConfig:agentFeeConfig,
				agentType:agentType,unionType:unionType,isProprod:isProprod,isAfterPay:isAfterPay,isAddedService:isAddedService,
				addedServiceCode:addedServiceCode,addedServiceCount:addedServiceCount,addedServiceName:addedServiceName,dentification:dentification,
				channelFlag:channelFlag,carAccidentSpecial:carAccidentSpecial,isMedicalMessage:isMedicalMessage,rateSubtract:rateSubtract,isPayment:isPayment,paymentType:paymentType,isRiskQuery:isRiskQuery,
				mfacadeIsReInsure:mfacadeIsReInsure,isPushedSalesInfo:isPushedSalesInfo,serviceType:serviceType,
				businessNature3:businessNature3,greenIndustryFirst:greenIndustryFirst,greenIndustrySecond:greenIndustrySecond,
				businessNature1:businessNature1,businessNature2:businessNature2,txChannel:txChannel,tkFlag:tkFlag,regressDept:regressDept,
				einvoiceType:einvoiceType,operatorNo:operatorNo,otherRate:otherRate,isEInvoice:isEInvoice});
		}
		if(flag=="update"){
			excuteUpdate({fileType:fileType,isCancelMessage:isCancelMessage,cancelReceiver:cancelReceiver,cancelTemplate:cancelTemplate,dicputeType:dicputeType,arbitrationDept:arbitrationDept,planNo:planNo,
				planName:planName,prodCode:prodCode,partnerNo:partnerNo,channleCode:channleCode_QD,channleType:channleType,
				newBsnsType:newBsnsType,categoryCode:categoryCode,dptCde:dptCde,commRate:commRate,empNo:empNo,empName:empName,
				teamCode:teamCode,teamName:teamName,agentNo:agentNo,agentName:agentName,protocolNo:protocolNo,serviceCode:serviceCode,serviceName:serviceName,
				state:state,isEpolicy:isEpolicy_val,isSeeMoney:isSeeMoney,isReceipt:isReceipt,checkStatus:checkStatus,
				specialArran:specialArran,notice:notice,
				isSendEmail:isEpolicyMali,emailTemplate:MailTemplate,
				epolicyDownloadWay:DownloadWay_val,receiptType:receiptType,selAccessory:selectAccessorylistStr,marketPreserveRate:marketPreserveRate,
				businessPerformanceRate:businessPerformanceRate,checkOpinion:checkOpinion,agentFeeConfig:agentFeeConfig,agentType:agentType,isAfterPay:isAfterPay,isAddedService:isAddedService,
				addedServiceCode:addedServiceCode,addedServiceName:addedServiceName,addedServiceCount:addedServiceCount,dentification:dentification,channelFlag:channelFlag,
				carAccidentSpecial:carAccidentSpecial,isMedicalMessage:isMedicalMessage,rateSubtract:rateSubtract,isPayment:isPayment,paymentType:paymentType,isRiskQuery:isRiskQuery,
				mfacadeIsReInsure:mfacadeIsReInsure,isPushedSalesInfo:isPushedSalesInfo,serviceType:serviceType,
				businessNature3:businessNature3,greenIndustryFirst:greenIndustryFirst,greenIndustrySecond:greenIndustrySecond,
				businessNature1:businessNature1,businessNature2:businessNature2,txChannel:txChannel,
				tkFlag:tkFlag,regressDept:regressDept,einvoiceType:einvoiceType,operatorNo:operatorNo,otherRate:otherRate,isEInvoice:isEInvoice,
				updateSpecialArran:updateSpecialArran});
		}
		if(flag=="copyAdd"){
			excuteAdd({fileType:fileType,isCancelMessage:isCancelMessage,cancelReceiver:cancelReceiver,cancelTemplate:cancelTemplate,dicputeType:dicputeType,arbitrationDept:arbitrationDept,planType:'3',
				saleArry:arr,oldPlanNo:planNo,oldAgentType:oldAgentType,oldPartnerNo:oldPartnerNo,
				planName:planName,prodCode:prodCode,partnerNo:partnerNo,channleCode:channleCode_QD,channleType:channleType,
				newBsnsType:newBsnsType,categoryCode:categoryCode,dptCde:dptCde,commRate:commRate,empNo:empNo,empName:empName,
				teamCode:teamCode,teamName:teamName,agentNo:agentNo,agentName:agentName,protocolNo:protocolNo,serviceCode:serviceCode,serviceName:serviceName,
				state:state,isEpolicy:isEpolicy_val,isSeeMoney:isSeeMoney,isReceipt:isReceipt,
				specialArran:specialArran,notice:notice,
				isSendEmail:isEpolicyMali,emailTemplate:MailTemplate,
				epolicyDownloadWay:DownloadWay_val,receiptType:receiptType,selAccessory:selectAccessorylistStr,marketPreserveRate:marketPreserveRate,
				businessPerformanceRate:businessPerformanceRate,checkOpinion:checkOpinion,checkStatus:checkStatus,isAfterPay:isAfterPay,isAddedService:isAddedService,
				addedServiceCode:addedServiceCode,addedServiceName:addedServiceName,addedServiceCount:addedServiceCount,agentFeeConfig:agentFeeConfig,agentType:agentType,unionType:unionType,isProprod:isProprod,
				dentification:dentification,channelFlag:channelFlag,
				carAccidentSpecial:carAccidentSpecial,isMedicalMessage:isMedicalMessage,rateSubtract:rateSubtract,isPayment:isPayment,paymentType:paymentType,isRiskQuery:isRiskQuery,
				mfacadeIsReInsure:mfacadeIsReInsure,isPushedSalesInfo:isPushedSalesInfo,serviceType:serviceType,
				businessNature3:businessNature3,greenIndustryFirst:greenIndustryFirst,greenIndustrySecond:greenIndustrySecond,
				businessNature1:businessNature1,businessNature2:businessNature2,txChannel:txChannel,tkFlag:tkFlag,regressDept:regressDept,
				einvoiceType:einvoiceType,operatorNo:operatorNo,otherRate:otherRate,isEInvoice:isEInvoice});
		}
	}
	//执行添加（新增/复制新增）
	function excuteAdd(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/addOrUpdateNlifePlan?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(result){
				$.closeLoading();
				if($.validate(result))return;

				var returnMap = result.data;
				if(returnMap.agentType=="1"){
					successBack('add');
				}else if(returnMap.agentType=="3" || returnMap.agentType=="4"||returnMap.agentType=="5"||returnMap.agentFeeConfig=="2"){
					window.location.href='<%=path%>/nlifePlanConfig/toEditNlifePlan?planNo='+returnMap.planNo;
				}else{
					successBack('add');
				}
			}
		});
	}

	//执行修改
	function excuteUpdate(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/addOrUpdateNlifePlan?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(data){
				$.closeLoading();
				if($.validate(data))return;
				successBack('edit');
			}
		});
	}

	//添加/编辑成功后返回主页面
	function successBack(flag){
		window.location.href = "<%=path%>/nlifePlanConfig/successBack?flag="+flag;
	}


	//“返回”按钮
	function goBackToList(){
		window.location.href='<%=path%>/nlifePlanConfig/list';
	}

	////加载个人代理(agentType==3)代理信息前，拼接参数
	function queryAgentInfoRela3(pageIndex){
		var size = 5;
		var planNo = $.trim($('#planNo').val());
		var agentType ="3";
		loadAgentInfoRela3({size:size,current:pageIndex,planNo:planNo,agentType:agentType});
	}
	//加载个人代理信息
	function loadAgentInfoRela3(param){
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoRelaPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;

				var fieldNames = "USER_CODE,USER_NAME,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE,COMM_RATE,market_rate,business_rate";
				var tableContent = creatTable1(fieldNames,page);
				var tableObj = $("#agentInfoRela3Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage3(param.current,6,page.maxPage,"45");
				var pageDIV = $("#agentInfoRela3PageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
			}
		});
	}

	//加载接口传入(agentType==6)代理信息前，拼接参数
	function queryAgentInfoRela6(pageIndex){
		var size = 5;
		var planNo = $.trim($('#planNo').val());
		var agentType ="6";
		loadAgentInfoRela6({size:size,current:pageIndex,planNo:planNo,agentType:agentType});
	}
	//加载总对总代理(agentType==4)代理信息前，拼接参数
	function queryAgentInfoRela4(pageIndex){
		var size = 5;
		var planNo = $.trim($('#planNo').val());
		var agentType ="4";
		loadAgentInfoRela4({size:size,current:pageIndex,planNo:planNo,agentType:agentType});
	}
	/**已配置的维度信息*/
	var tdate="";
	var title="";
	function createTable(weids){
		var weidl=weids.split(",");
		tdate="";
		title="";
		for (var i = 0; i < weidl.length; i++) {
			if(weidl[i]==0){
				title='<th style="text-align: center;">机构</th>';
				tdate="branch,"
			}else if(weidl[i]==1){
				title+='<th style="text-align: center;">业务来源</th>';
				tdate+="nchannelSource,"
			}else if(weidl[i]==2){
				title+='<th style="text-align: center;">产品大类</th>';
				tdate+="nproductType,"
			}else if(weidl[i]==3){
				title+='<th style="text-align: center;">代理人代码/业务员代码</th>';
				tdate+="empNo,"
			}
		}
		title+='<th style="text-align: center;">手续费比例（%）</th><th style="text-align: center;">市场维护费比例（%）</th><th style="text-align: center;">业务绩效比例（%）</th>';
		tdate+='commRate,marketRate,businessRate';
	}
	//加载已配置的三费信息
	function loadAgentInfoRela6(param){
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoRelaPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if(page.data&&page.data.length>0){
					if ($("#agentFeeConfig").val() == "2"){
						$('#agentNameTitle').html("跟单费用配置名称：" + page.data[0].agentNo + "-" + page.data[0].agentName);
					}else {
						$('#agentNameTitle').html("跟单费用配置名称："+page.data[0].agentName);
					}
					if(param.current=='1'){
						createTable(page.data[0].weidConfig);
					}
					$("#agentFeeTitle").html(title)
				}
				/*  var fieldNames="branch,commRate,marketRate,businessRate"; */
				var fieldNames=tdate;
				var tableContent = creatTable1(fieldNames,page);
				var tableObj = $("#agentInfoRela6Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage3(param.current,6,page.maxPage,"64");
				var pageDIV = $("#agentInfoRela6PageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
			}
		});
	}//加载已配置的三费信息结束
	//加载总对总代理信息
	function loadAgentInfoRela4(param){
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoRelaPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				var fieldNames;
				var flang=false;
				if($.validate(page))return;
				$.each(page.data, function(k, v){
					if(v.TRANSTYPE=='1'){
						flang=true;
					}
					return false;
				});
				if(page.data==''){
					flang=true;
				}
				if(flang){
					fieldNames = "BRANCH,BRANCH_NAME,USERCODE,USERNAME,ZONE,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE,COMM_RATE,market_rate,business_rate";
					$("#agentInfoRela4Table tr:eq(1) td:eq(0)").attr("colspan",22).siblings().remove();

				}else{
					if(	$("#agentInfoRela4Table tr th:eq(2)").html()=="用户名"){
						$("#agentInfoRela4Table tr th:eq(2)").remove();
						$("#agentInfoRela4Table tr th:eq(2)").remove();
					}
					fieldNames = "BRANCH,BRANCH_NAME,ZONE,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE,COMM_RATE,market_rate,business_rate";
					$("#agentInfoRela4Table tr:eq(1) td:eq(0)").attr("colspan",20).siblings().remove();

				}
				var tableContent = creatTable1(fieldNames,page);
				var tableObj = $("#agentInfoRela4Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage3(param.current,6,page.maxPage,"46");
				var pageDIV = $("#agentInfoRela4PageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
			}
		});
	}
	//加载联合出单代理(agentType==5)代理信息前，拼接参数
	function queryAgentInfoRela5(pageIndex){
		var size = 5;
		var planNo = $.trim($('#planNo').val());
		var agentType ="5";
		loadAgentInfoRela5({size:size,current:pageIndex,planNo:planNo,agentType:agentType});
	}

	//加载联合出单代理信息
	function loadAgentInfoRela5(param){
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoRelaPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				var fieldNames;
				var flang=false;
				if($.validate(page))return;
				fieldNames = "DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE,COMM_RATE,market_rate,business_rate,Key1,key2,key3,key4,key5";
				var tableContent = creatTable1(fieldNames,page);
				var tableObj = $("#agentInfoRela5Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage3(param.current,6,page.maxPage,"60");
				var pageDIV = $("#agentInfoRela5PageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
			}
		});
	}

	//点击"配置区域联合出单销售业务信息"
	function openAgentInfoZon5Div(){
		$('#ZonconfStatus_5').val('');
		$('#ZonbranchName5').val('');
		zonMap.clear();
		//加载第一页总对总代理信息
		queryAgentInfoZon5(1);
	}
	//加载区域联合出单代理信息前，拼接参数
	function queryAgentInfoZon5(pageIndex){
		var planNo = $.trim($('#planNo').val());
		if(planNo.length==0){
			$.message("error", "请先保存投保方案");
			return;
		}
		var partnerNo = $.trim($("#partnerNo").val());
		if(planNo.length==0){
			$.message("error", "请先选择合作伙伴代码");
			return;
		}
		var agentType = '5';
		var size = 10;
		var branchName = $.trim($("#ZonbranchName5").val());
		var ZonconfStatu=$.trim($("#ZonconfStatus_5").val());
		loadAgentInfoZon5({size:size,current:pageIndex,planNo:planNo,partnerNo:partnerNo,isFlag:ZonconfStatu,branchName:branchName});
	}

	//加载区域联合出单代理信息
	function loadAgentInfoZon5(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoZon5PageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				var flang=false;
				var fieldNames ;
				$.closeLoading();
				if($.validate(page))return;
				fieldNames = "DEP,DEPT_ABR,ISFLAG@TDH,MCOMMRATE@TDH,LMARKET@TDH,MBUSINESS@TDH";
				var checkboxObj ="<input name='agentInfoZon5checkbox' type='checkbox'>";
				var inputObj ="<input style='width:100%' name='commRate_Zon5' onchange='zonRateChange5(this)'/>@<input style='width:100%' name='marketRate_Zon5' onchange='zonRateChange5(this)'/>@<input style='width:100%' name='businessRate_Zon5' onchange='zonRateChange5(this)'/>";
				var tableContent = creatTable1(fieldNames,page,checkboxObj,inputObj);
				var tableObj = $("#agentInfoZon5Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				var strPage =  creatChannelPage4(param.current,6,page.maxPage,"90");
				var pageDIV = $("#agentInfoZon5Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);

				$("#agentInfoZon5Table").find("tr").each(function(){
					var branch=$(this).children("td:eq(1)").html();
					var isFlag=$(this).children("td:eq(3)").html();
					var commRate=$(this).children("td:eq(4)").html();
					var marketRate=$(this).children("td:eq(5)").html();
					var busyRate=$(this).children("td:eq(6)").html();
					if(isFlag=='Y'){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentInfoZon5checkbox']").prop("checked",true);
						if(commRate==-1){
							commRate='';
						}
						if(marketRate==-1){
							marketRate='';
						}
						if(busyRate==-1){
							busyRate='';
						}
						var o=new Object();
						o.branch=branch;
						o.commRate=commRate;
						o.marketRate=marketRate;
						o.businessRate=busyRate;
						if(branchs==''){
							branchs=branch;
						}else{
							branchs+=","+branch;
						}
						zonMap.put(branch,o);
						$(this).find("input[name='commRate_Zon5']").val(commRate);
						$(this).find("input[name='marketRate_Zon5']").val(marketRate);
						$(this).find("input[name='businessRate_Zon5']").val(busyRate);
					}
				});
				$('#agentInfoZon5Div').OpenDiv();
				bindradio();
			}
		});
	}
	function zonRateChange5(obj){
		var rate=$(obj).attr("name");
		var branch= $(obj).parent().parent().children(" td:eq(1)").html();
		var o=zonMap.get(branch);
		if(o){
			//手续费比例
			if("commRate_Zon5"==rate){
				o.commRate= $(obj).val()+"";
			}else if("marketRate_Zon5"==rate){
				o.marketRate=$(obj).val()+"";;
			}else if("businessRate_Zon5"==rate){
				o.businessRate=$(obj).val()+"";
			}
			zonMap.put(branch,o);
		}
	}
	//点击"配置个人销售业务信息", 弹出个人代理信息选择层
	function openAgentInfo3Div(){
		//加载第一页个人代理信息
		queryAgentInfo3(1);
	}
	//点击"配置激活卡销售业务信息", 弹出激活卡代理信息选择层
	function openAgentInfo7Div(){
		//加载第一页激活卡代理信息
		queryAgentInfo7(1);
	}
	//点击"配置区域总对总销售业务信息", 弹出总对总代理信息选择层
	function openAgentInfoZon4Div(){
		$('#ZonconfStatus_4').val('');
		$('#ZonbranchName').val('');
		zonMap.clear();
		//加载第一页总对总代理信息
		queryAgentInfoZon4(1);
	}
	//点击"配置总对总销售业务信息", 弹出总对总代理信息选择层
	function openAgentInfo4Div(){
		//加载第一页总对总代理信息
		queryAgentInfo4(1);
	}

	//点击"配置联合出单销售业务信息", 弹出联合出单代理信息选择层
	function openAgentInfo5Div(){
		//加载第一页联合出单代理信息
		queryAgentInfo5(1);
	}

	//加载个人代理信息前，拼接参数
	function queryAgentInfo3(pageIndex){
		var planNo = $.trim($('#planNo').val());
		if(planNo.length==0){
			$.message("error", "请先保存投保方案");
			return;
		}
		var partnerNo = $.trim($("#partnerNo").val());
		if(planNo.length==0){
			$.message("error", "请先选择合作伙伴代码");
			return;
		}

		var selectedAgentInfo3 = $("input[name='agentInfo3checkbox']:checked");
		if(selectedAgentInfo3.length!=0){
			var flag= false;
			selectedAgentInfo3.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var commRate= $.trim(obj.val());
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate)){
						flag = true;
						$.message("error","手续费比例：只能录入0到1之间的有效数字(6位小数)");
						window.setTimeout(function(){ obj.focus(); }, 0);
						return false;
					}
				}
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo3.length!=0){
			selectedAgentInfo3.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				obj.branch= $(this).parent().parent().children("td:eq(4)").html();
				obj.cardapplicant= $(this).parent().parent().children("td:eq(7)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.market= $(this).parent().parent().find("input[name='marketRate_Div']").val();
				obj.business= $(this).parent().parent().find("input[name='businessRate_Div']").val();
				map.put(obj.id,obj);
			});
		}

		var agentType = '3';
		var size = 10;

		var confStatus = $.trim($("#confStatus_3").val());
		var userCode = $.trim($("#userCode").val());
		var userName = $.trim($("#userName").val());

		loadAgentInfo3({size:size,current:pageIndex,planNo:planNo,partnerNo:partnerNo,agentType:agentType,confStatus:confStatus,userCode:userCode,userName:userName});
	}
	//加载总对总代理信息前，拼接参数
	function queryAgentInfo4(pageIndex){
		var planNo = $.trim($('#planNo').val());
		if(planNo.length==0){
			$.message("error", "请先保存投保方案");
			return;
		}
		var partnerNo = $.trim($("#partnerNo").val());
		if(planNo.length==0){
			$.message("error", "请先选择合作伙伴代码");
			return;
		}

		var selectedAgentInfo4 = $("input[name='agentInfo4checkbox']:checked");
		if(selectedAgentInfo4.length!=0){
			var flag= false;
			selectedAgentInfo4.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var commRate= $.trim(obj.val());
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate)){
						flag = true;
						$.message("error","手续费比例：只能录入0到1之间的有效数字(最多6位小数)");
						window.setTimeout(function(){ obj.focus(); }, 0);
						return false;
					}
				}
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo4.length!=0){
			selectedAgentInfo4.each(function(i){
				var obj = new Object();
				var columnes=$("#agentInfo4Table").find("th").length;
				if(columnes==21){
					obj.id= $(this).parent().parent().children("td:eq(1)").html();
					obj.cardapplicant= $(this).parent().parent().children("td:eq(12)").html();
				}else if(columnes==23){
					obj.id= $(this).parent().parent().children("td:eq(1)").html();
					obj.cardapplicant= $(this).parent().parent().children("td:eq(14)").html();
				}
				obj.branch= $(this).parent().parent().children("td:eq(6)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.market= $(this).parent().parent().find("input[name='marketRate_Div']").val();
				obj.business= $(this).parent().parent().find("input[name='businessRate_Div']").val();
				map.put(obj.id,obj);
			});
		}

		var agentType = '4';
		var size = 10;

		var confStatus = $.trim($("#confStatus_4").val());
		var branch = $.trim($("#branch").val());
		var branchName = $.trim($("#branchName").val());
		var deptId =  $.trim($("#deptId").val());
		var deptName = $.trim($("#deptName").val());

		loadAgentInfo4({size:size,current:pageIndex,planNo:planNo,partnerNo:partnerNo,agentType:agentType,confStatus:confStatus,branch:branch,branchName:branchName,deptId:deptId,deptName:deptName});
	}
	//加载区域总对总代理信息前，拼接参数
	function queryAgentInfoZon4(pageIndex){
		var planNo = $.trim($('#planNo').val());
		if(planNo.length==0){
			$.message("error", "请先保存投保方案");
			return;
		}
		var partnerNo = $.trim($("#partnerNo").val());
		if(planNo.length==0){
			$.message("error", "请先选择合作伙伴代码");
			return;
		}
		var agentType = '4';
		var size = 10;
		var branchName = $.trim($("#ZonbranchName").val());
		var ZonconfStatu=$.trim($("#ZonconfStatus_4").val());
		loadAgentInfoZon4({size:size,current:pageIndex,planNo:planNo,partnerNo:partnerNo,isFlag:ZonconfStatu,branchName:branchName});
	}

	//加载联合出单代理信息前，拼接参数
	function queryAgentInfo5(pageIndex){
		var planNo = $.trim($('#planNo').val());
		if(planNo.length==0){
			$.message("error", "请先保存投保方案");
			return;
		}
		var partnerNo = $.trim($("#partnerNo").val());
		if(planNo.length==0){
			$.message("error", "请先选择合作伙伴代码");
			return;
		}

		var selectedAgentInfo5 = $("input[name='agentInfo5checkbox']:checked");
		if(selectedAgentInfo5.length!=0){
			var flag= false;
			selectedAgentInfo5.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var commRate= $.trim(obj.val());
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate)){
						flag = true;
						$.message("error","手续费比例：只能录入0到1之间的有效数字(6位小数)");
						window.setTimeout(function(){ obj.focus(); }, 0);
						return false;
					}
				}
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo5.length != 0){
			selectedAgentInfo5.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				obj.cardapplicant= $(this).parent().parent().children("td:eq(7)").html();
				obj.branch= $(this).parent().parent().children("td:eq(3)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.market= $(this).parent().parent().find("input[name='marketRate_Div']").val();
				obj.business= $(this).parent().parent().find("input[name='businessRate_Div']").val();
				map.put(obj.id,obj);
			});
		}

		var agentType = '5';
		var size = 10;

		var confStatus = $.trim($("#confStatus_5").val());
		var key1 = $.trim($("#key1").val());
		var key2 = $.trim($("#key2").val());
		var key3 = $.trim($("#key3").val());
		var key4 = $.trim($("#key4").val());
		var key5 = $.trim($("#key5").val());
		var unionType=$('#unionType').val();
		loadAgentInfo5({size:size,current:pageIndex,planNo:planNo,agentType:agentType,confStatus:confStatus,key1:key1,key2:key2,key3:key3,key4:key4,key5:key5,unionType:unionType});
	}

	//加载个人代理信息
	function loadAgentInfo3(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;

				var checkboxObj ="<input name='agentInfo3checkbox' type='checkbox'>";
				var fieldNames = "ID@TDH,USER_CODE,USER_NAME,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE";
				var inputObj ="<input style='width:100%' name='commRate_Div' onchange='changeCommRate_Div(this)'/>@<input style='width:100%' name='marketRate_Div' onchange='changeCommRate_Div1(this)'/>@<input style='width:100%' name='businessRate_Div' onchange='changeCommRate_Div2(this)'/>";
				var tableContent = creatTable1(fieldNames,page,checkboxObj,inputObj);
				var tableObj = $("#agentInfo3Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage4(param.current,6,page.maxPage,"47");
				var pageDIV = $("#agentInfo3Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);

				$("#agentInfo3Table").find("tr").each(function(){
					var id = $(this).children("td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentInfo3checkbox']").prop("checked",true);
						$(this).find("input[name='commRate_Div']").val(map.get(id).commrate);
						$(this).find("input[name='marketRate_Div']").val(map.get(id).market);
						$(this).find("input[name='businessRate_Div']").val(map.get(id).business);
					}
				});

				$('#agentInfo3Div').OpenDiv();

				bindradio();
			}
		});
	}
	//加载区域总对总代理信息
	function loadAgentInfoZon4(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoZon4PageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				var flang=false;
				var fieldNames ;
				$.closeLoading();
				if($.validate(page))return;
				fieldNames = "DEP,DEPT_ABR,ISFLAG@TDH,MCOMMRATE@TDH,LMARKET@TDH,MBUSINESS@TDH";
				var checkboxObj ="<input name='agentInfoZon4checkbox' type='checkbox'>";
				var inputObj ="<input style='width:100%' name='commRate_Zon' onchange='zonRateChange(this)'/>@<input style='width:100%' name='marketRate_Zon' onchange='zonRateChange(this)'/>@<input style='width:100%' name='businessRate_Zon' onchange='zonRateChange(this)'/>";
				var tableContent = creatTable1(fieldNames,page,checkboxObj,inputObj);
				var tableObj = $("#agentInfoZon4Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage4(param.current,6,page.maxPage,"71");
				var pageDIV = $("#agentInfoZon4Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);

				$("#agentInfoZon4Table").find("tr").each(function(){
					var branch=$(this).children("td:eq(1)").html();
					var isFlag=$(this).children("td:eq(3)").html();
					var commRate=$(this).children("td:eq(4)").html();
					var marketRate=$(this).children("td:eq(5)").html();
					var busyRate=$(this).children("td:eq(6)").html();
					if(isFlag=='Y'){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentInfoZon4checkbox']").prop("checked",true);
						if(commRate==-1){
							commRate='';
						}
						if(marketRate==-1){
							marketRate='';
						}
						if(busyRate==-1){
							busyRate='';
						}
						var o=new Object();
						o.branch=branch;
						o.commRate=commRate;
						o.marketRate=marketRate;
						o.businessRate=busyRate;
						if(branchs==''){
							branchs=branch;
						}else{
							branchs+=","+branch;
						}
						zonMap.put(branch,o);
						$(this).find("input[name='commRate_Zon']").val(commRate);
						$(this).find("input[name='marketRate_Zon']").val(marketRate);
						$(this).find("input[name='businessRate_Zon']").val(busyRate);
					}
				});
				$('#agentInfoZon4Div').OpenDiv();
				bindradio();
			}
		});
	}
	//加载区域总对总结束
	//加载总对总代理信息
	function loadAgentInfo4(param){
		var agentFeeConfig = $("#agentFeeConfig").val();
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				var flang=false;
				var fieldNames ;
				$.closeLoading();
				if($.validate(page))return;
				var isNull = false;
				if(page.data==null){
					var tableObj = $("#agentInfo4Table");
					$.message("error","请配置销售管理信息");
					tableObj.find("tbody").remove();
					isNull = true;
					$("#agentInfo4Page").attr("style","display:none");
					return ;
				}else{
					$("#agentInfo4Page").show();
				}
				$.each(page.data, function(k, v){
					if(v.TRANSTYPE=='1'){
						flang=true;
					}
					return false;
				});

				var checkboxObj ="<input name='agentInfo4checkbox' type='checkbox'>";
				if(flang){
					fieldNames = "ID@TDH,CHANNEL_CODE@TDH,SUB_CHANNEL_CODE@TDH,BRANCH,BRANCH_NAME,DEPT_CNAME,USERNAME,ZONE,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE";
					$("#agentInfo4Table tr:eq(1) td:eq(0)").attr("colspan",19).siblings().remove();
				}else {
					if($("#agentInfo4Table tr th:eq(3)").html()=="用户名"){
						$("#agentInfo4Table tr th:eq(3)").remove();
						$("#agentInfo4Table tr th:eq(3)").remove();
					}
					$("#agentInfo4Table tr:eq(1) td:eq(0)").attr("colspan",17).siblings().remove();
					fieldNames = "ID@TDH,CHANNEL_CODE@TDH,SUB_CHANNEL_CODE@TDH,BRANCH,BRANCH_NAME,DPT_CDE,DEPT_CNAME,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE";
				}
				var inputObj="";
				if('2'==agentFeeConfig){
					var	inputObj ="<input style='width:100%' name='commRate_Div' onchange='changeCommRate_Div(this)'/>@<input style='width:100%' name='marketRate_Div' onchange='changeCommRate_Div1(this)'/>@<input style='width:100%' name='businessRate_Div' onchange='changeCommRate_Div2(this)'/>";
				}else{
					inputObj ="<input disabled='disabled' style='width:100%' class='input_text' name='commRate_Div' onchange='changeCommRate_Div(this)'/>@<input disabled='disabled' style='width:100%' name='marketRate_Div' class='input_text' onchange='changeCommRate_Div1(this)'/>@<input disabled='disabled' class='input_text' style='width:100%' name='businessRate_Div' onchange='changeCommRate_Div2(this)'/>";
				}
				var tableContent = creatTable1(fieldNames,page,checkboxObj,inputObj);
				var tableObj = $("#agentInfo4Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage4(param.current,6,page.maxPage,"48");
				var pageDIV = $("#agentInfo4Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);

				$("#agentInfo4Table").find("tr").each(function(){
					var id = $(this).children("td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentInfo4checkbox']").prop("checked",true);
						$(this).find("input[name='commRate_Div']").val(map.get(id).commrate);
						$(this).find("input[name='marketRate_Div']").val(map.get(id).market);
						$(this).find("input[name='businessRate_Div']").val(map.get(id).business);
					}
				});

				$('#agentInfo4Div').OpenDiv();




				bindradio();
			}
		});
	}
	//加载联合出单代理信息
	function loadAgentInfo5(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				var fieldNames ;
				$.closeLoading();
				if($.validate(page))return;
				if(page.data==null){
					$.message("error","请配置销售管理信息");
					return ;
				}
				var checkboxObj ="<input name='agentInfo5checkbox' type='checkbox'>";
				fieldNames = "ID@TDH,CHANNEL_CODE@TDH,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE,key1,key2,key3,key4,key5";
				var inputObj ="<input style='width:100%' name='commRate_Div' onchange='changeCommRate_Div(this)'/>@<input style='width:100%' name='marketRate_Div' onchange='changeCommRate_Div1(this)'/>@<input style='width:100%' name='businessRate_Div' onchange='changeCommRate_Div2(this)'/>";

				var tableContent = creatTable1(fieldNames,page,checkboxObj,inputObj);
				var tableObj = $("#agentInfo5Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage4(param.current,6,page.maxPage,"61");
				var pageDIV = $("#agentInfo5Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				$("#agentInfo5Table").find("tr").each(function(){
					var id = $(this).children("td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentInfo5checkbox']").prop("checked",true);
						$(this).find("input[name='commRate_Div']").val(map.get(id).commrate);
						$(this).find("input[name='marketRate_Div']").val(map.get(id).market);
						$(this).find("input[name='businessRate_Div']").val(map.get(id).business);
					}
				});

				$('#agentInfo5Div').OpenDiv();

				bindradio();
			}
		});
	}

	//校验手续费比例格式
	function changeCommRate_Div(obj){
		var reg=/^0(\.\d{0,6})?$/;
		if(obj.value!=""){
			if(!reg.test(obj.value)){
				$.message("error","手续费比例：只能录入0到1之间的有效数字");
				window.setTimeout(function(){ obj.focus(); }, 0);
				return false;
			}
		}
	}
	//校验手续费比例格式
	function changeCommRate_Div1(obj){
		var reg=/^0(\.\d{0,6})?$/;
		if(obj.value!=""){
			if(!reg.test(obj.value)){
				$.message("error","市场维护费比例：只能录入0到1之间的有效数字");
				window.setTimeout(function(){ obj.focus(); }, 0);
				return false;
			}
		}
	}
	//校验手续费比例格式
	function changeCommRate_Div2(obj){
		var reg=/^0(\.\d{0,6})?$/;
		if(obj.value!=""){
			if(!reg.test(obj.value)){
				$.message("error","业务绩效比例：只能录入0到1之间的有效数字");
				window.setTimeout(function(){ obj.focus(); }, 0);
				return false;
			}
		}
	}
	//点击“保存(已选的个人代理信息)”
	function saveChosenAgentInfo3(){
		var riskType = $("#riskType").val();
		var isInternetRisk = $("#isInternetRisk").val();
		var risklimit = $("#riskToplimit").val();

		var selectedAgentInfo3 = $("input[name='agentInfo3checkbox']:checked");
		if(selectedAgentInfo3.length!=0){
			var flag= false;
			selectedAgentInfo3.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var obj1=$(this).parent().parent().find("input[name='marketRate_Div']");
				var obj2=$(this).parent().parent().find("input[name='businessRate_Div']");
				var commRate= obj.val();
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate)){
						$.message("error","手续费比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj.focus(); }, 0);
						return false;
					}
				}
				var commRate1= obj1.val();
				if(commRate1!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate1)){
						$.message("error","市场维护费比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj1.focus(); }, 0);
						return false;
					}
				}
				var commRate2= obj2.val();
				if(commRate2!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate2)){
						$.message("error","业务绩效比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj2.focus(); }, 0);
						return false;
					}
				}
				if(commRate!=""&&commRate!=null&&commRate1!=""&&commRate1!=null&&commRate2!=""&&commRate2!=null&&risklimit!=null){
					var riskToplimit = parseFloat(risklimit).toFixed(6);
					//互联网专属
					if("Y" == isInternetRisk || "y" == isInternetRisk){
						var allRate = (parseFloat(commRate) + parseFloat(commRate1) + parseFloat(commRate2)).toFixed(6);
						if(allRate > riskToplimit){
							$.message("error","手续费比例、市场维护费比例、业务绩效比例之和大于条款比例上限");
							return false;
						}
					} else{
						if(parseFloat(commRate).toFixed(6) > riskToplimit && "1" == riskType){
							$.message("error","手续费比例大于条款比例上限");
							flag = true;
							return flag;
						}
					}
				}
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo3.length!=0){
			selectedAgentInfo3.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				obj.branch= $(this).parent().parent().children("td:eq(4)").html();
				obj.cardapplicant= $(this).parent().parent().children("td:eq(7)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.market= $(this).parent().parent().find("input[name='marketRate_Div']").val();
				obj.business= $(this).parent().parent().find("input[name='businessRate_Div']").val();
				map.put(obj.id,obj);
			});
		}
		var planNo = $("#planNo").val();

		if(map.isEmpty()){
			$.message("error", "请选择销售业务信息");
			return;
		}else{
			agentInfoList = new Array();
			for(i in map.keys()){
				var key = map.keys()[i];
				agentInfoList.push(map.get(key));
			}

			/* mapBak.clear();
			for(i in map.keys()){
				var key = map.keys()[i];
		        mapBak.put(key,map.get(key));
		    } */
			agentInfoListStr=JSON.stringify(agentInfoList);
		}
		updateAgentInfoRela({planNo:planNo,agentInfoListStr:agentInfoListStr,agentType:'3'});

	}
	//点击“保存(已选的总对总代理信息)”
	function saveChosenAgentInfo4(){
		var riskType = $("#riskType").val();
		var isInternetRisk = $("#isInternetRisk").val();
		var risklimit = $("#riskToplimit").val();
		var selectedAgentInfo4 = $("input[name='agentInfo4checkbox']:checked");
		if(selectedAgentInfo4.length!=0){
			var flag= false;
			selectedAgentInfo4.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var obj1=$(this).parent().parent().find("input[name='marketRate_Div']");
				var obj2=$(this).parent().parent().find("input[name='businessRate_Div']");
				var commRate= obj.val();
				//费用比例和小于1大于等于0
				var totalRate=0;
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate)){
						$.message("error","手续费比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj.focus(); }, 0);
						return false;
					}
					totalRate=totalRate+parseFloat(commRate)
				}
				var commRate1= obj1.val();
				if(commRate1!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate1)){
						$.message("error","市场维护费比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj1.focus(); }, 0);
						return false;
					}
					totalRate=totalRate+parseFloat(commRate1)
				}
				var commRate2= obj2.val();
				if(commRate2!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate2)){
						$.message("error","业务绩效比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj2.focus(); }, 0);
						return false;
					}
					totalRate=totalRate+parseFloat(commRate2)
				}
				if(totalRate>=1){
					flag = true;
					$.message("error","三费之和为0到1之间");
					window.setTimeout(function(){ obj.focus(); }, 0);
					return false;
				}
				if(commRate!=""&&commRate!=null&&commRate1!=""&&commRate1!=null&&commRate2!=""&&commRate2!=null&&risklimit!=null){
					var riskToplimit = parseFloat(risklimit).toFixed(6);
					//互联网专属
					if("Y" == isInternetRisk || "y" == isInternetRisk){
						var allRate = (parseFloat(commRate) + parseFloat(commRate1) + parseFloat(commRate2)).toFixed(6);
						if(allRate > riskToplimit){
							$.message("error","手续费比例、市场维护费比例、业务绩效比例之和大于条款比例上限");
							flag = true;
							return flag;
						}
					} else{
						if(parseFloat(commRate).toFixed(6) > riskToplimit && "1" == riskType){
							$.message("error","手续费比例大于条款比例上限");
							flag = true;
							return flag;
						}
					}
				}
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo4.length!=0){
			selectedAgentInfo4.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				var columnes=$("#agentInfo4Table").find("th").length;
				if(columnes==21){
					obj.cardapplicant= $(this).parent().parent().children("td:eq(12)").html();
				}else if(columnes==23){
					obj.cardapplicant= $(this).parent().parent().children("td:eq(14)").html();
				}
				obj.branch=$(this).parent().parent().children("td:eq(7)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.market= $(this).parent().parent().find("input[name='marketRate_Div']").val();
				obj.business= $(this).parent().parent().find("input[name='businessRate_Div']").val();
				map.put(obj.id,obj);
			});
		}
		var planNo = $("#planNo").val();
		for(i in map.keys()){
			var key = map.keys()[i];
			if(key==undefined){
				map.remove(key)
			}
		}
		if(map.isEmpty()){
			$.message("error", "请选择销售业务信息");
			return;
		}else{
			agentInfoList = new Array();
			for(i in map.keys()){
				var key = map.keys()[i];
				agentInfoList.push(map.get(key));
			}
			agentInfoListStr=JSON.stringify(agentInfoList);
		}
		updateAgentInfoRela({planNo:planNo,agentInfoListStr:agentInfoListStr,agentType:'4'});

	}

	//点击“保存(已选的联合出单代理信息)”
	function saveChosenAgentInfo5(){
		var riskType = $("#riskType").val();
		var isInternetRisk = $("#isInternetRisk").val();
		var risklimit = $("#riskToplimit").val();

		var selectedAgentInfo5 = $("input[name='agentInfo5checkbox']:checked");
		if(selectedAgentInfo5.length!=0){
			var flag= false;
			selectedAgentInfo5.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var obj1=$(this).parent().parent().find("input[name='marketRate_Div']");
				var obj2=$(this).parent().parent().find("input[name='businessRate_Div']");
				var commRate= obj.val();
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate)){
						$.message("error","手续费比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj.focus(); }, 0);
						return false;
					}
				}
				var commRate1= obj1.val();
				if(commRate1!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate1)){
						$.message("error","市场维护费比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj1.focus(); }, 0);
						return false;
					}
				}
				var commRate2= obj2.val();
				if(commRate2!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate2)){
						$.message("error","业务绩效比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj2.focus(); }, 0);
						return false;
					}
				}
				if(commRate!=""&&commRate!=null&&commRate1!=""&&commRate1!=null&&commRate2!=""&&commRate2!=null&&risklimit!=null){
					var riskToplimit = parseFloat(risklimit).toFixed(6);
					//互联网专属
					if("Y" == isInternetRisk || "y" == isInternetRisk){
						var allRate = (parseFloat(commRate) + parseFloat(commRate1) + parseFloat(commRate2)).toFixed(6);
						if(allRate > riskToplimit){
							$.message("error","手续费比例、市场维护费比例、业务绩效比例之和大于条款比例上限");
							flag = true;
							return flag;
						}
					} else{
						if(parseFloat(commRate).toFixed(6) > riskToplimit && "1" == riskType){
							$.message("error","手续费比例大于条款比例上限");
							flag = true;
							return flag;
						}
					}
				}
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo5.length!=0){
			selectedAgentInfo5.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				obj.branch= $(this).parent().parent().children("td:eq(3)").html();
				obj.cardapplicant= $(this).parent().parent().children("td:eq(7)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.market= $(this).parent().parent().find("input[name='marketRate_Div']").val();
				obj.business= $(this).parent().parent().find("input[name='businessRate_Div']").val();
				map.put(obj.id,obj);
			});
		}
		var planNo = $("#planNo").val();
		for(i in map.keys()){
			var key = map.keys()[i];
			if(key==undefined){
				map.remove(key)
			}
		}
		if(map.isEmpty()){
			$.message("error", "请选择销售业务信息");
			return;
		}else{
			agentInfoList = new Array();
			for(i in map.keys()){
				var key = map.keys()[i];
				agentInfoList.push(map.get(key));
			}

			agentInfoListStr=JSON.stringify(agentInfoList);
		}
		updateAgentInfoRela({planNo:planNo,agentInfoListStr:agentInfoListStr,agentType:'5'});
	}

	//更新方案关联的代理信息
	function updateAgentInfoRela(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/updateAgentInfoRela?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(data){
				$.closeLoading();
				if($.validate(data))return;

				var agentType= $.trim($("#agentType").val());
				if(agentType=="3"){
					mapBak.clear();
					for(i in map.keys()){
						var key = map.keys()[i];
						mapBak.put(key,map.get(key));
					}
					queryAgentInfoRela3(1);
					$("#agentInfo3Div").CloseDiv();
				}
				if(agentType=="4"){
					mapBak.clear();
					for(i in map.keys()){
						var key = map.keys()[i];
						mapBak.put(key,map.get(key));
					}
					queryAgentInfoRela4(1);
					$("#agentInfo4Div").CloseDiv();
				}
				if(agentType=="5"){
					mapBak.clear();
					for(i in map.keys()){
						var key = map.keys()[i];
						mapBak.put(key,map.get(key));
					}
					queryAgentInfoRela5(1);
					$("#agentInfo5Div").CloseDiv();
				}
				/* if(agentType=="7"){
					queryAgentInfoRela7(1);
				} */
			}
		});
	}

	//关闭 个人/总对总销售业务信息配置  弹出层
	function closeAgentInfoDiv(obj){
		var selectedAgentInfo = $("input[name^=agentInfo]:checked");
		if(selectedAgentInfo.length!=0){
			selectedAgentInfo.each(function(i){
				$(this).prop("checked",false);
			});
		}

		map.clear();
		for(i in mapBak.keys()){
			var key = mapBak.keys()[i];
			map.put(key,mapBak.get(key));
		}

		$("#confStatus_3").val("");
		$("#userCode").val("");
		$("#userName").val("");

		$("#confStatus_4").val("");
		$("#branch").val("");
		$("#branchName").val("");

		$("#confStatus_5").val("");
		$("#key1").val("");
		$("#key2").val("");
		$("#key3").val("");
		$("#key4").val("");
		$("#key5").val("");

		$("#"+obj).CloseDiv();
	}
	function SeeMoneyChange (){
		$('#notice_1').hide();
		var isSeeMoney =$('#isSeeMoney').val();
		if(isSeeMoney== "N"){
			//$('#isDredgePay').val(1);
			//$('#isDredgePay').attr("disabled",true);
			//$("#isDredgePay").css({"background-color": "#ccc"});
		}else if(isSeeMoney=='YD'){
			//$("#isDredgePay").attr("disabled",false);
			//$("#isDredgePay").css({"background-color": ""});
			$('#notice_1').show();
		}
		else{
			//$("#isDredgePay").attr("disabled",false);
			//$("#isDredgePay").css({"background-color": ""});
		}
	}
	function bsnsTypeChange(){
		var newBsnsCode = $("#newBsnsType").val();
		var bsnsTypeCode = $("#bsnsType").val();

		//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填，其他非必填
		if(bsnsTypeCode!="19002"&&bsnsTypeCode!="19003"){
			$("#agentNo ~ span").remove(".red");
			/* $("#agentNo").attr("disabled",true);
			$("#agentNo").css({"background-color": "#ccc"}); */
			$("#agentNo").val("");
			$("#agentName ~ span").remove(".red");
			/* $("#agentName").attr("disabled",true);
			$("#agentName").css({"background-color": "#ccc"}); */
			$("#agentName").val("");
			$("#protocolNo").val("");
			/* $("#protocolNo").css({"background-color": "#ccc"});
			$("#protocolNo").attr("disabled",true); */
			$("#protocolNo ~ span").remove(".red");
		}else{
// 			if($("#agentNo ~ span").length==0){
// 				$("#agentNo").parent().append("<span class='red'>*</span>");
// 			}
			$("#agentNo").attr("disabled",false);
			$("#agentNo").css({"background-color": ""});
			$("#agentName").attr("disabled",false);
			$("#agentName").css({"background-color": ""});
			$("#protocolNo").attr("disabled",false);
			$("#protocolNo").css({"background-color": ""});
			if($("#agentNo ~ span").length==0){
				$("#agentNo").parent().append("<span class='red'>*</span>");
			}
			if($("#protocolNo ~ span").length==0){
				$("#protocolNo").parent().append("<span class='red'>*</span>");
			}
			if($("#agentName ~ span").length==0){
				$("#agentName").parent().append("<span class='red'>*</span>");
			}
		}
	}
	//是否电子发票
	function epolicyInvoiceChange(){
		var isEInvoice =$('#isEInvoice').val();
		if(isEInvoice=='Y'){
			$('#einvoiceType').show();
		}else {
			$('#einvoiceType').hide();
		}
	}
	//下载方式改变方式
	function downloadWayChange(flag1){
		var flag=$('#DownloadWay').val();
		if(flag=='1'){
			$('#fileTypeSpan').show()
		}else{
			$('#fileTypeSpan').hide()
		}
		var isEpolicyMali =$('#isEpolicyMali').val();
		if(isEpolicyMali=='1'){
			setEmailTemplate(flag1);
		}
	}
	//文件方式改变
	function fileTypeChange(){
		var isEpolicyMali =$('#isEpolicyMali').val();
		if(isEpolicyMali=='1'){
			setEmailTemplate();
		}
	}
	$(document).ready(function(){
		/* salesInfoReadOnly(); */
		saveRiskInfo();
	});
	//加载激活卡代理信息前，拼接参数
	function queryAgentInfo7(pageIndex){
		var planNo = $.trim($('#planNo').val());
		if(planNo.length==0){
			$.message("error", "请先保存投保方案");
			return;
		}
		var partnerNo = $.trim($("#partnerNo").val());
		if(planNo.length==0){
			$.message("error", "请先选择合作伙伴代码");
			return;
		}

		var selectedAgentInfo7 = $("input[name='agentInfo7checkbox']:checked");
		if(selectedAgentInfo7.length!=0){
			var flag= false;
			selectedAgentInfo7.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var commRate= $.trim(obj.val());
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate)){
						flag = true;
						$.message("error","手续费比例：只能录入0到1之间的有效数字(6位小数)");
						window.setTimeout(function(){ obj.focus(); }, 0);
						return false;
					}
				}
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo7.length!=0){
			selectedAgentInfo7.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				obj.cardapplicant= $(this).parent().parent().children("td:eq(7)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.market= $(this).parent().parent().find("input[name='marketRate_Div']").val();
				obj.business= $(this).parent().parent().find("input[name='businessRate_Div']").val();
				map.put(obj.id,obj);
			});
		}

		var agentType ='7';
		var size = 10;

		var confStatus = $.trim($("#confStatus_7").val());
		var userCode = $.trim($("#userCodeCard").val());
		var userName = $.trim($("#userNameCard").val());

		loadAgentInfo7({size:size,current:pageIndex,planNo:planNo,partnerNo:partnerNo,agentType:agentType,confStatus:confStatus,userCode:userCode,userName:userName});
	}

	//加载激活卡代理信息
	function loadAgentInfo7(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryAgentInfoPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;

				var checkboxObj ="<input name='agentInfo7checkbox' type='checkbox'>";
				var fieldNames = "ID@TDH,USER_CODE,USER_NAME,DPT_CDE,SERVICE_CODE,SERVICE_NAME,EMP_NO,EMP_NAME,CARD_APPLICANT,TEAM_CODE,CHANNLECODEDES,CHANNLETYPEDES,NEWBSNSTYPEDES,AGENT_NO,PROTOCOL_NO,C_BRKR_NME,C_OPR_CDE";
				var inputObj ="<input style='width:100%' name='commRate_Div' onchange='changeCommRate_Div(this)'/>@<input style='width:100%' name='marketRate_Div' onchange='changeCommRate_Div1(this)'/>@<input style='width:100%' name='businessRate_Div' onchange='changeCommRate_Div2(this)'/>";
				var tableContent = creatTable1(fieldNames,page,checkboxObj,inputObj);
				var tableObj = $("#agentInfo7Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);

				var strPage = creatChannelPage4(param.current,6,page.maxPage,"81");
				var pageDIV = $("#agentInfo7Page");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);

				$("#agentInfo7Table").find("tr").each(function(){
					var id = $(this).children("td:eq(1)").html();
					if(map.containsKey(id)){
						$(this).addClass("table_highlighter");
						$(this).children("td:eq(0)").find("input[name='agentInfo7checkbox']").prop("checked",true);
						$(this).find("input[name='commRate_Div']").val(map.get(id).commrate);
						$(this).find("input[name='marketRate_Div']").val(map.get(id).market);
						$(this).find("input[name='businessRate_Div']").val(map.get(id).business);
					}
				});

				$('#agentInfo7Div').OpenDiv();

				bindradio();
			}
		});
	}
	//点击“保存(已选的激活卡代理信息)”
	function saveChosenAgentInfo7(){
		var selectedAgentInfo7 = $("input[name='agentInfo7checkbox']:checked");
		if(selectedAgentInfo7.length!=0){
			var flag= false;
			selectedAgentInfo7.each(function(i){
				var obj=$(this).parent().parent().find("input[name='commRate_Div']");
				var obj1=$(this).parent().parent().find("input[name='marketRate_Div']");
				var obj2=$(this).parent().parent().find("input[name='businessRate_Div']");
				var commRate= obj.val();
				if(commRate!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate)){
						$.message("error","手续费比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj.focus(); }, 0);
						return false;
					}
				}
				var commRate1= obj1.val();
				if(commRate1!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate1)){
						$.message("error","市场维护费比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj1.focus(); }, 0);
						return false;
					}
				}
				var commRate2= obj2.val();
				if(commRate2!=""){
					var reg=/^0(\.\d{0,6})?$/;
					if(!reg.test(commRate2)){
						$.message("error","业务绩效比例：只能录入0到1之间的有效数字(最多6位小数)");
						flag = true;
						window.setTimeout(function(){ obj2.focus(); }, 0);
						return false;
					}
				}
			});
			if(flag){
				return;
			}
		}
		if(selectedAgentInfo7.length!=0){
			selectedAgentInfo7.each(function(i){
				var obj = new Object();
				obj.id= $(this).parent().parent().children("td:eq(1)").html();
				obj.cardapplicant= $(this).parent().parent().children("td:eq(7)").html();
				obj.commrate= $(this).parent().parent().find("input[name='commRate_Div']").val();
				obj.market= $(this).parent().parent().find("input[name='marketRate_Div']").val();
				obj.business= $(this).parent().parent().find("input[name='businessRate_Div']").val();
				map.put(obj.id,obj);
			});
		}
		var planNo = $("#planNo").val();

		if(map.isEmpty()){
			$.message("error", "请选择销售业务信息");
			return;
		}else{
			agentInfoList = new Array();
			for(i in map.keys()){
				var key = map.keys()[i];
				agentInfoList.push(map.get(key));
			}

			mapBak.clear();
			for(i in map.keys()){
				var key = map.keys()[i];
				mapBak.put(key,map.get(key));
			}
			agentInfoListStr=JSON.stringify(agentInfoList);
		}

		updateAgentInfoRela({planNo:planNo,agentInfoListStr:agentInfoListStr});

		$("#agentInfo7Div").CloseDiv();
	}

	function closeDetailDiv() {
		$("#productDetail").CloseDiv();

		mainContent = "";

		$("#mainContentDiv").html("");
	}


	var covContent = "";
	var mainContent = "";
	/* 显示详情 */
	function showDetail() {

		var prodcode =$.trim($('#prodCode').val());
		var data={prodCode:prodcode};
		$.ajax({
			url:"nlifeProductConfig/queryProdInfoByCode",
			type:'POST',
			async:true,
			dataType:String,
			data:data,
			success:function(page){
			},
			error:function(page){
				/* 因为返回的不是json对象   所以进error方法 */
				data = JSON.parse(page.responseText);
				$('#prod_no').html(data["prodCode"]);/* 产品代码 */
				$('#prod_name').html(data.prodName);/* 产品名称 */
				$('#max_delay_day').html(data.maxDelayDay+"天");/* 最长延时起保天数 */
				$('#min_delay_day').html(data.minDelayDay+"天");/* 最短延时起保天数 */
				/* 及时起保 */
				var instant = data.instant=="Y" ? "是" : "否"
				$('#instant').html(instant);/* 是否及时起保 */
				/* 转化日期为标准年月日 */
				var unit = data.pppUnit;
				if(unit == "d"){
					$('#start_date').html(data.minDays + "至" + data.maxDays + "日");/* 起始时间 */
				}else if(unit == "m"){
					$('#start_date').html(data.minDays + "至" + data.maxDays + "月");/* 起始时间 */
				}
				else{
					$('#start_date').html(data.minDays + "至" + data.maxDays + "年");/* 起始时间 */
				}

				$('#max_cancle_day').html(data.longestCancelDay+"天");/* 最长注销天数 */
				$('#max_Number').html(data.maxNumber + "份");/* 最多份数*/

				/* 搞出来条款信息 */
				param = {current:1,size:6,tradProdCode:prodcode}
				showRiskDetail(param);
			}
		})
		$('#productDetail').OpenDiv();
	}


	/* 显示条款信息的方法 */
	function showRiskDetail(param){
		$.ajax({
			url : "nlifeProductConfig/loadAddedRiskInfo",
			type : 'POST',
			async : true,
			dataType:'json',
			data:param,
			success : function(page) {
				//设置最后一个单元格内容
				var lastbutton = "<a href='javascript:void(this)' id='d{CORE_RISK_CODE}' name='{PRMRY_FLAG}' onClick='showRiskCov();'>查看责任</a>";
				var tableContent = creatTable7("PROD_CODE@TDH,CORE_RISK_CODE,RISK_NAME,PRMRY_FLAG?[{0:'主险'};{1:'附加险'};{2:'第一主险'}]",page,null,null);
				var tableObj = $("#nlife_risk_cov_detail");

				/* 条款信息的标题行 */
				var titleRisk = "<div id='nlife_div_drive_xz_tableInfo' style='display: block; width: 100%;'><table id='nlife_risk_cov_detail' class='table_02' align='center' style='width: 100%;'><thead><th width='45' nowrap='nowrap'>条款代码</th><th width='30' nowrap='nowrap'>条款名称</th><th width='15' nowrap='nowrap'>主附加险标识</th>"
				var endRisk = "</tbody></table>";
				/* 责任信息的标题行 */



				tableObj.find("tbody").remove();
				/* 每行条款下面有很多责任 */
				var tbContents = tableContent.split("</tr>");
				for (var i = 0; i < tbContents.length - 1; i++) {
					var riskContent = titleRisk + tbContents[i] + endRisk;
					var coreRiskCode = tbContents[i].split("</td>")[1].substring(4);
					/* var coreRiskCode = $('#nlife_risk_cov_detail').find('tr').eq(i).find('td').eq(1).text(); */
					var prodCode = param['tradProdCode'];
					var nParam = {prodCode:prodCode,coreRiskCode:coreRiskCode};
					/* loadCoverage(nParam); */
					loadCoverage(nParam);
					mainContent = "<div id = 'mainContentDiv'>" + mainContent + riskContent + covContent + "</div>";


				}
				$("#nlife_risk_cov_detail").after(mainContent);


			},

		});
	}

	/*
		显示责任信息的方法
		param 格式 json =
		{prodCode:    ,coreRiskCode:   }
	*/
	function loadCoverage(param){
		$.openLoading();
		$.ajax({
			url : "nlifeProductConfig/queryNewLifeCoverage",
			type : 'POST',
			async : false,
			dataType:'json',
			data:param,
			success : function(page) {
				$.closeLoading();

				var calStr='';
				var firstbutton ="<input class='input_fxk' name='checkboxCov' type='checkbox' value='#' display='none' onclick='logicHandle(this)'>";
				var lastbutton = "<select name='nlifeisInputAmt'onchange='checkAmountisAllowInput(this)'class='select_1'style='visibility: hidden;width:60px;'><option value='Y'>固定值</option><option value='N'>接口传入</option></select><select style='visibility: visible;width:60px;'class='select_1' name='amtType' onchange='amtTypeChange(this)'><option value='2'selected='selected'>每人保额</option><option value='1'>共享保额</option></select><input type='hidden' value='{AMTTYPE}'/>&nbsp<input class='input_text'style='width:50px;visibility: visible'maxlength='10'name='nlifecovAmt'type='text'value='{COVAMT}'>@<input class='input_text'style='width:100px;visibility: visible;'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)' name='nlifenoAmtRate' type='text'value='{AMTRATE}'>@<input class='input_text' name='nlifenoAmtLimit' style='width:80px;visibility: visible;'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)'type='text'value='{AMTLIMIT}'>@<input class='input_text'style='width:90px;visibility: visible'maxlength='13'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)'name='nlifenoCalimAmount'type='text'value='{NOCALIMAMOUNT}'>@<input class='input_text'style='width:90px;visibility: visible'maxlength='5'onKeyUp='clearNoNum(event,this)'onBlur='checkNum(this)'name='nlifeclaimRate'type='text'value='{CLAIMRATE}'>@<select name='nlifecalId'class='select_1'style='visibility: visible;width:100px;'><option value=''>---请选择---</option>"+calStr+"</select><a  style='color: blue;padding-left:5px; ' name='downConfig' onclick='calDocDowlaod()' href='javascript:void(this)'>算法文档</a>";
				var tableContent = creatTable7("coreCovCode,covName,covAmt,amtLimit,noCalimAmount,claimRate,calId",page,null,null);
				var titleCov = "<div id='nlife_div_driver_xz_tableInfo' style='display: block;width:95%'><table class='table_02' id='nlife_cov_detail' align='center' style='width: 95%;'><thead><th nowrap='nowrap'>责任代码</th><th nowrap='nowrap'>责任名称</th><th nowrap='nowrap'>保额</th><th nowrap='nowrap'>保额上限</th><th nowrap='nowrap'>免赔额</th><th nowrap='nowrap'>赔付比率</th><th nowrap='nowrap'>责任保费算法</th></thead><tbody>"
				var endCov = "</tbody></table></div>";
				covContent = titleCov + tableContent + endCov;

				$("#editCovDiv").OpenDiv();
			}
		});
	}

	function showDetailByRadio(){
		var tradProdCode='';
		var radioProduct = $("input[name='radioProduct']:checked");
		if(radioProduct.val()!=undefined){
			var flag=1;
			if(exportflag){
				flag=2;
			}
			var tradProdCode = radioProduct.parent().parent().children(" td:eq("+flag+")").html();
			var prodcode = tradProdCode;
			var data={prodCode:prodcode};
			$.ajax({
				url:"nlifeProductConfig/queryProdInfoByCode",
				type:'POST',
				async:true,
				dataType:String,
				data:data,
				success:function(page){
				},
				error:function(page){
					/* 因为返回的不是json对象   所以进error方法 */
					data = JSON.parse(page.responseText);
					$('#prod_no').html(data["prodCode"]);/* 产品代码 */
					$('#prod_name').html(data.prodName);/* 产品名称 */
					$('#max_delay_day').html(data.maxDelayDay+"天");/* 最长延时起保天数 */
					$('#min_delay_day').html(data.minDelayDay+"天");/* 最短延时起保天数 */
					/* 及时起保 */
					var instant = data.instant=="Y" ? "是" : "否"
					$('#instant').html(instant);/* 是否及时起保 */
					/* 转化日期为标准年月日 */


					var unit = data.pppUnit;
					if(unit == "d"){
						$('#start_date').html(data.minDays + "至" + data.maxDays + "日");/* 起始时间 */
					}else if(unit == "m"){
						$('#start_date').html(data.minDays + "至" + data.maxDays + "月");/* 起始时间 */
					}
					else{
						$('#start_date').html(data.minDays + "至" + data.maxDays + "年");/* 起始时间 */
					}

					$('#max_cancle_day').html(data.longestCancelDay+"天");/* 最长注销天数 */
					$('#max_Number').html(data.maxNumber + "份");/* 最多份数*/

					/* 搞出来条款信息 */
					param = {current:1,size:6,tradProdCode:prodcode}
					showRiskDetail(param);
				}
			})
			$('#productDetail').OpenDiv();
		}
	}

	function exportCovDetail(obj){
		var prodNo = 	$('#prod_no').text();
		var data = {prodCode:prodNo};

		window.location.href='<%=basePath%>nlifeProductConfig/covExcelDownload?prodCode='+prodNo;

	}
	function isInsurEinvoiceChange(){
		var isInsuranceEinvoice=$("#isInsuranceEinvoice").val();
		if(isInsuranceEinvoice=='Y'){
			$("#payEinvoice").val('1');
			$('#payEinvoice').attr("disabled",true);
			$('#payEinvoice').css("background-color","#ccc");
		}else{
			$('#payEinvoice').attr("disabled",false);
			$('#payEinvoice').css("background-color","");
		}
		setEmailTemplate();
	}


	//20190507新增车加意特约
	function unionTypeChange(param){
		if("CYLH"==$(param).val()){
			$("#CAR_ACCIDENT_SPECIAL").show();
			$("#unionMessageConfig").show();
		}else{
			$("#CAR_ACCIDENT_SPECIAL").hide();
			$("#unionMessageConfig").hide();
		}
	}


	//保存条款信息
	function saveRiskInfo(){
		var prodCode = $("#prodCode").val();
		var date = {prodCode:prodCode};
		$.ajax({
			url : "nlifePlanConfig/queryMainRiskOrFirstRisk",
			type : 'POST',
			async : true,
			data : date,
			dataType : "json",
			success:function(map){
				var riskToplimit = parseFloat(map["riskToplimit"]).toFixed(6);
				var isInternetRisk = map["isInternetRisk"];
				var riskType = map["riskType"];
				$("#isInternetRisk").val(isInternetRisk);
				$("#riskToplimit").val(riskToplimit);
				$("#riskType").val(riskType);

			}
		});
	}

	function isSaveCoinFeeConfig(agentNo){
		var resultCode = "";
		var prodCode = $("#prodCode").val();
		var isInternetRisk = $("#isInternetRisk").val();
		var riskType = $("#riskType").val();
		$.ajax({
			url : "nlifePlanConfig/queryTopFeeBranch",
			type : "POST",
			async : false,
			data : {agentNo:agentNo,prodCode:prodCode,isInternetRisk:isInternetRisk,riskType:riskType},
			dataType : "json",
			success:function(resultMap){
				resultCode = resultMap["resultCode"];
			}
		});
		return resultCode;
	}

	function addAddedServiceInfo(){
		var isAddedService = $.trim($('#isAddedService').val());
		if(isAddedService =='Y'){
			$('#addedServiceInfo1').show();
			$('#addedServiceInfo2').show();
			$('#addedServiceInfo3').show();
			$('.addedServiceInfo4').show();
		}else{
			$('#addedServiceInfo1').hide();
			$('#addedServiceInfo2').hide();
			$('#addedServiceInfo3').hide();
			$('.addedServiceInfo4').hide();
		}
	}
</script>

<body>
<%-- 是否互联网专属产品--%>
<input type="hidden"  id="isInternetRisk" value=""/>
<%-- 条款比例上限--%>
<input type="hidden"  id="riskToplimit" value=""/>
<input type="hidden"  id="riskType" value=""/>
<div class="current">
	<table class="current_table_1">
		<tbody>
		<tr class="f2">
			<td>
				<img src="./images/current_1.jpg">
			</td>
			<td class="current_table_1_td">
				<img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
				<span style=" color:#136bab; ">新意健险产品管理
                         <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>方案配置
                         <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>
                         	<c:if test="${not empty planNo }">投保方案编辑&nbsp;</c:if>
				<c:if test="${empty planNo }">投保方案新增</c:if>
				</span>
			</td>
			<td><img src="./images/current_3.jpg"></td>
		</tr>
		</tbody>
	</table>
</div>

<c:choose>
	<c:when test="${not empty planNo}">
		<input type="hidden" value="${planNo }" id="hidePlanNo">
	</c:when>
	<c:when test="${not empty oldPlanNo}">
		<input type="hidden" value="${oldPlanNo }" id="hidePlanNo">
	</c:when>
</c:choose>
<input type="hidden" value="${businessNature2List}" id="businessNature2List">
<form id="inputForm">
	<table class="table_05">
		<tbody>
		<tr>
			<td colspan="4" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px; background-image:url(images/centent_1.jpg)">
				<c:if test="${not empty planNo}">投保方案编辑</c:if>
				<c:if test="${empty planNo}">投保方案新增</c:if>
			</td>
		</tr>
		<tr>
			<th width="10%">投保方案号：</th>
			<td width="40%"><input name="planNo" id="planNo" readonly="readonly" style="background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;<span  style="${ptnEnv}">上线方案专用：<input type="checkbox" id='isProprod'/>&nbsp;<img src="/manager/images/caldef.jpg" title="此选项可保证测试环境与生产环境方案号一致及防止方案号冲突。仅供后续会升级正式环境的方案使用，不上线的方案不允许勾选！"></span></td>
			<th width="10%">投保方案名称：</th>
			<td width="40%"><input id="planName"  id="planName" class="input_text" ><span class="red">*</span></td>
		</tr>
		<tr>
			<th>产品编号：</th>
			<td>
				<input name="prodCode" id="prodCode" readonly="readonly" style="background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;
				<c:if test="${empty planNo}">
					<input type="button"  class="input_button_2" id="searchProdBtn" value="请选择" onClick="openNlifeProdDiv(1,this)"/>
				</c:if>
				<c:if test="${not empty planNo}">
					<input type="button" disabled="disabled" id="searchProdBtn" value="请选择" onClick="openNlifeProdDiv(1,this)"/>
					<input type="button"  id="searchProdBtn" value="显示详情" onClick="showDetail()"/>
				</c:if>
				<!--  	<input type="hidden" id="agentType" />   -->
				<input type="hidden" id="prodSaleCode"/><!-- 选择产品时赋值，该值是为了向销管获取代理信息时传参 -->
			</td>
			<th>合作伙伴代码：</th>
			<td>
				<input name="partnerNo" id="partnerNo" readonly="readonly" style="background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;
				<c:if test="${empty planNo}">
					<input type="button"  class="input_button_2" id="searchChannelInfoBtn" value="请选择" onClick="openChannelInfoDiv()"/>
				</c:if>
				<c:if test="${not empty planNo}">
					<input type="button" disabled="disabled"  id="searchChannelInfoBtn" value="请选择" onClick="openChannelInfoDiv()"/>
				</c:if>
			</td>
		</tr>
		<tr>
			<th id='cRate'>手续费比例：</th>
			<td>
				<input name="commRate" id="commRate" class="input_text" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
				<span class="red" style="margin-left: -5px">*</span>&nbsp;<span id="commRateSpan" class="blue"></span>
				<!-- 手续费比例上下限，验证使用 -->
				<input id="feeMaxRate" type="hidden" value="1"/>
				<input id="feeMinRate" type="hidden" value="0"/>
			</td>
			<th id='mRate'>管理费比例：</th>
			<td>
				<input name="marketPreserveRate" id="marketPreserveRate" class="input_text" value="0" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
				<span class="red" style="margin-left: -5px">*</span>
			</td>
		</tr>
		<tr>
			<th id='bRate'>业务管理费比例：</th>
			<td>
				<input name="businessPerformanceRate" id="businessPerformanceRate" class="input_text"  value="0"  onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
				<span class="red" style="margin-left: -5px">*</span>
			</td>
			<th>其他费用：
			<td>
				<input name="otherRate" id="otherRate" class="input_text"  value="0"  onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
				<span class="red" style="margin-left: -5px">*</span>
			</td>
			</th>
		</tr>
		<tr>
			<th>是否见费出单：
			</th>
			<td>
				<div style="float:left;  height: 34px ;width:50%;  padding-top:11px;"> <select id="isSeeMoney" class="select_1 valid" onchange="SeeMoneyChange()" style="visibility: visible;">
					<option value="N">否</option>
					<option value="Y">是</option>
					<option value="YD">见费已缴费</option>
				</select></div>
				<div style="height: 45px ;width:46%;float: left; ">
					<span class="red" id='notice_1' style="padding-left: 15px; display: none;">注意：此为非常规流程，请线下沟通确认</span></div>
			</td>
			<th>方案销售类型：</th>
			<td>
				<select id="agentType" name="agentTypeSel" onchange="agentChange()" class="select_1 valid" style="visibility: visible;">					
						<option value="1" title="合作伙伴代理">合作伙伴代理</option>
				</select>
				<select name="unionType"  id="unionType" class="select_1 valid" style="visibility: visible;display: none;" onchange="unionTypeChange(this)">
					<option value="">请选择联合出单方案</option>
					<c:forEach var ="unionType" items="${unionTypes}">
						<option value="${unionType.code}">${unionType.codeName}</option>
					</c:forEach>
				</select>
				<!-- 车加意关联信息配置按钮 默认隐藏，联合出单-接口传入 && 车加意联合 时显示 -->
				<input type="button" id="unionMessageConfig" onclick="openMessageConfig()" style="display: none" value="车加意-关联信息配置" title="注意：仅车加意方案需进行此配置，需在编辑页面操作">
			</td>
		</tr>
		<tr>
		<tr>
			<th id="deptCode101">出单机构：</th>
			<td id="deptCode102">
				<input id="dptCde" readonly="readonly"  style="background-color: #ccc;" class="input_text"><span class="red"  name="wxflag">*</span>&nbsp;
				<input type="button"  class="input_button_2" id="searchDeptBtn" value="请选择" onClick="openDeptDiv('1')"/>
			</td>
			<th id="regressDeptTh">归属机构：</th>
			<td id="regressDeptTd">
				<input id="regressDept" readonly="readonly"  style="background-color: #ccc;" class="input_text"><span class="red"  name="wxflag">*</span>&nbsp;
				<input type="button"  class="input_button_2" id="searchDeptBtn" value="请选择" onClick="openDeptDiv('2')"/>
			</td>
		</tr>
		<!--begin --------------------------根据产品销售方式的不同改变以下内容-------------------------------------- -->
		<!--agentType1  合作伙伴代理   -->
		<tr id="agentType101">
			<th>业务员代码：</th>
			<td>
<!-- 				<div id="empNo_select_div" style="display: none">
					<select id="empNo_select" onchange="changeEmpNo()" class="select_1"></select>
				</div> -->
				<input id="empNo" class="input_text" maxlength="10"/>
				<span class="red" style="margin-left: -5px"  name="wxflag">*</span>&nbsp;
			</td>
			<th>业务员名称：</th>
			<td><input id="empName" class="input_text"><span class="red" >*</span></td>
		</tr>
		<tr id="quDao01">
			<th>业务来源 1 ：</th>
			<td>
				<select id="businessNature1"  class="select_1 valid" onchange="changeFirstbusinessNature(this)" style="visibility: visible;">
					<option value="">-----请选择-----</option>
					<c:forEach var ="nature" items="${businessNature1List}">
						<option value="${nature.code}" title="${nature.codeName}">${nature.codeName}</option>
					</c:forEach>
				</select>
			</td>
			<th>业务来源 2：</th>
			<td>
				<select id="businessNature2"  class="select_1 valid" onchange="" style="visibility: visible;">
					<option value="">-----请先选择业务来源 1-----</option>
					<c:forEach var ="nature" items="${businessNature2List}">
						<option value="${nature.code}" title="${nature.codeName}">${nature.code}-${nature.codeName}</option>
					</c:forEach>
				</select>
			</td>

		</tr>
		<tr id="quDao02">
			<th>业务来源 3：</th>
			<td>
				<select id="businessNature3"  class="select_1 valid" onchange="" style="visibility: visible;">
					<c:forEach var ="nature" items="${businessNature3List}">
						<option value="${nature.code}" title="${nature.codeName}">${nature.code}-${nature.codeName}</option>
					</c:forEach>
				</select>
			</td>
			<th>操作员代码：</th>
			<td>
				<input id="operatorNo" class="input_text">
			</td>
		</tr>
		<tr id="agentType103">
			<th>代理人代码：</th>
			<td>
				<!-- <div id="agentNo_select_div" style="display: none">
					<select id="agentNo_select" onchange="changeAgentNo()" class="select_1"></select>
				</div> -->
				<input id="agentNo" class="input_text"/><span class="red" name="wxflag">*</span>
			</td>
			<th>代理协议号：</th>
			<td><input id="protocolNo" class="input_text" maxlength="13"/><span class="red" name="wxflag">*</span></td>
		</tr>
		<tr id="greenIndustryInfo">
			<th>绿色产业标识一级：</th>
			<td>
				<select id="greenIndustryFirst"  class="select_1 valid" onchange="" style="visibility: visible;">
					<option value="">-----请选择绿色产业标识一级-----</option>
					<c:forEach var ="nature" items="${greenIndustryFirstList}">
						<option value="${nature.code}" title="${nature.codeName}">${nature.codeName}</option>
					</c:forEach>
				</select>
			</td>
			<th>绿色产业标识二级 ：</th>
			<td>
				<select id="greenIndustrySecond"  class="select_1 valid" onchange="" style="visibility: visible;">
					<option value="">-----请选择绿色产业标识二级-----</option>
					<c:forEach var ="nature" items="${greenIndustrySecondList}">
						<option value="${nature.code}" title="${nature.codeName}">${nature.codeName}</option>
					</c:forEach>
				</select>
			</td>
			<td></td>
		</tr>
		<tr>
			<th>统信渠道：</th>
			<td>
				<select id="txChannel1st"  class="select_1 valid" onchange="txChannelChange(this)" style="visibility: visible;">
					<c:forEach var ="nature" items="${txChannel1stList}">
						<option value="${nature.code}" title="${nature.codeName}">${nature.codeName}</option>
					</c:forEach>
				</select>
				<select id="txChannel2nd"  class="select_1 valid" onchange="" style="visibility: visible;">
					<option value="">-----请先选择统信渠道一级-----</option>		
					<c:forEach var ="nature" items="${txChannel2ndList}">
						<option value="${nature.code}" title="${nature.codeName}">${nature.codeName}</option>
					</c:forEach>
				</select>
			</td>
			<th>统括标志 ：</th>
			<td>
				<select id="tkFlag"  class="select_1 valid" style="visibility: visible;">
					<option value="">-----请选择统括标志 -----</option>
					<c:forEach var ="nature" items="${tkFlagList}">
						<option value="${nature.code}" title="${nature.codeName}">${nature.codeName}</option>
					</c:forEach>
				</select>
			</td>
			<td></td>
		</tr>
		
		
		<!--广东分公司个人销售业务信息 -->
		<tr id="sale1" style="display:none">
			<th>跟单人员配置信息：</th>
			<td colspan="3"><input type="button" onclick="opensaleDiv()" value="广东销售信息配置"/></td>
		</tr>
		<tr id="sale2" style="display:none">
			<td colspan="4">
				<div style="width:1100px; height:200px; overflow:scroll;">
					<table id="agentType3Table"  style="width:99%;">
						<thead>
						<tr style="background-color: C0C0C0;">
							<th style="border: #292421 solid 1px;width:100px;text-align: center;">序号</th>
							<th style="border: #292421 solid 1px;width:100px;text-align: center;">销售员类型<span style="margin-left:-5px" class="red">*</span></th>
							<th style="border: #292421 solid 1px;width:100px;text-align: center;">销售人员代码<span style="margin-left:-5px" class="red">*</span></th>
							<th style="border: #292421 solid 1px;width:100px;text-align: center;">销售人员姓名</th>
							<th style="border: #292421 solid 1px;width:100px;text-align: center;">执业证号</th>
							<th style="border: #292421 solid 1px;width:100px;text-align: center;">代理机构号</th>
							<th style="border: #292421 solid 1px;width:100px;text-align: center;">代理机构名称</th>
							<th style="border: #292421 solid 1px;width:100px;text-align: center;">分摊比例<span style="margin-left:-5px" class="red">*</span></th>
						</tr>
						</thead>
						<tbody id='saleShowDiv'>
						</tbody>
					</table>
				</div>
			</td>
		</tr>	
		<!--agentType4   总对总代理   -->
	

		<!--agentType5   联合出单代理   -->
		<tr id="agentType501" style="display:none">
			<c:if test="${not empty planNo }">
				<th>联合出单销售业务信息：</th>
				<td colspan="3"><input type="button" onclick="openAgentInfo5Div()" value="配置联合出单销售渠道信息"/>&nbsp;<input type="button" onclick="openAgentInfoZon5Div()" value="配置联合出单销售区域"/>&nbsp;<input type="button" value="清除联合出单销售渠道信息" onclick="clearAgentInfoZon5Div()"/></td>
			</c:if>
			<c:if test="${empty planNo }">
				<th>联合出单销售业务信息：</th>
				<!-- <td colspan="3"><input type="hidden" disabled="disabled" onclick="openAgentInfo5Div()" value="配置联合出单销售渠道信息"/></td> -->
				<td colspan="3"><input type="button" onclick="openAgentInfo5Div()" disabled="disabled" value="配置联合出单销售渠道信息"/>&nbsp;<input type="button" disabled="disabled" onclick="openAgentInfoZon5Div()" value="配置联合出单销售区域"/>&nbsp;<input type="button" disabled="disabled" value="清除联合出单销售渠道信息" onclick="clearAgentInfoZon5Div()"/></td>
			</c:if>
		</tr>
		<c:if test="${not empty planNo || not empty oldPlanNo }">
			<tr id="agentType502">
				<td colspan="4">
					<div style="width:1100px; height:auto; overflow:scroll;">
						<table id="agentInfoRela5Table" style="width:2180px;">
							<thead>
							<tr style="background-color: C0C0C0;">
								<!-- <th style="width:80px;text-align: center;">网点代码</th>
                               <th style="width:100px;text-align: center;">网点名称</th>
                               <th style="width:80px;text-align: center;">用户名</th>
                               <th style="width:80px;text-align: center;">姓名</th>
                               <th style="width:80px;text-align: center;">区域代码</th> -->
								<th style="width:80px;text-align: center;">出单机构</th>
								<th style="width:80px;text-align: center;">服务代码</th>
								<th style="width:80px;text-align: center;">服务名称</th>
								<th style="width:80px;text-align: center;">业务员代码</th>
								<th style="width:80px;text-align: center;">业务员名称</th>
								<th style="width:80px;text-align: center;">单证领用人 </th>
								<th style="width:80px;text-align: center;">团队代码 </th>
								<th style="width:90px;text-align: center;">归属渠道</th>
								<th style="width:90px;text-align: center;">渠道类型</th>
								<th style="width:100px;text-align: center;">业务来源</th>
								<th style="width:80px;text-align: center;">代理人编码</th>
								<th style="width:80px;text-align: center;">代理协议号</th>
								<th style="width:80px;text-align: center;">代理人名称</th>
								<th style="width:80px;text-align: center;">处理人</th>
								<th style="width:80px;text-align: center;">手续费比例 </th>
								<th style="width:85px;text-align: center;">市场维护费比例</th>
								<th style="width:80px;text-align: center;">业务绩效比例 </th>
								<th style="width:80px;text-align: center;">Key1</th>
								<th style="width:80px;text-align: center;">Key2</th>
								<th style="width:80px;text-align: center;">Key3</th>
								<th style="width:80px;text-align: center;">Key4</th>
								<th style="width:80px;text-align: center;">Key5</th>
							</tr>
							</thead>
							<tfoot>
							<tr>
								<td colspan="22">
									<div id="agentInfoRela5PageDIV" class="page"></div>
								</td>
							</tr>
							</tfoot>
							<tbody>
							</tbody>
						</table>
					</div>
				</td>
			</tr>
		</c:if>
		<!--agentType6  销售类型6 跟单费用配置接口传入  -->
		<tr id="agentType601" style="display:none">
			<c:if test="${not empty planNo }">
				<th>第三方传入方案跟单费用配置：</th>
				<td colspan="3"><input type="button" onclick="openAgentInfo6Div(1)" value="跟单费用配置选择"/></td>
			</c:if>
			<c:if test="${empty planNo }">
				<th>第三方传入方案跟单费用配置：</th>
				<td colspan="3"><input type="button" disabled="disabled" onclick="openAgentInfo6Div(1)" value="跟单费用配置选择"/></td>
			</c:if>
		</tr>
		<c:if test="${not empty planNo || not empty oldPlanNo }">
			<tr id="agentType602">
				<td colspan="4">
					<div style="height:auto; overflow:scroll">
						<span id='agentNameTitle'></span>
						<table id="agentInfoRela6Table" style="width: 100%" >
							<thead>
							<tr style="background-color: C0C0C0;" id="agentFeeTitle">
								<th style="text-align: center;">机构</th>
								<th style="text-align: center;">手续费比例（%）</th>
								<th style="text-align: center;">业务绩效比例（%）</th>
								<th style="text-align: center;">市场维护费比例（%）</th>
							</tr>
							</thead>
							<tfoot>
							<tr>
								<td colspan="22">
									<div id="agentInfoRela6PageDIV" class="page" style="text-align:center"></div>
								</td>
							</tr>
							</tfoot>
							<tbody>
							</tbody>
						</table>
					</div>
				</td>
			</tr>
		</c:if>
		<!-- end --------------------------根据产品销售方式的不同改变以上内容-------------------------------------- -->
		<tr>
			<th>争议处理方式：</th>
			<td>
				<select name="dicputeType" onchange="dicputeType1()" id="dicputeType" class="select_1 valid" style="visibility: visible;">
					<c:forEach var ="dicputeType" items="${dicputeTypes}">
						<option value="${dicputeType.code}">${dicputeType.codeName}</option>
					</c:forEach>
				</select>&nbsp

			</td>
			<th>仲裁委员会名称：</th>
			<td><select name="arbitrationDept"  id="arbitrationDept" class="select_1 valid" style="visibility: visible;">
				<c:forEach var ="dicputeType" items="${arbitrationDepts}">
					<option value="${dicputeType.code}">${dicputeType.codeName}</option>
				</c:forEach>
			</select>
			</td>
		</tr>
		<tr>
			<th>是否发送电子发票短信：</th>
			<td>
				<select id="isEInvoice" class="select_1 valid" style="visibility: visible;" onchange="epolicyInvoiceChange()">
					<option value="N">否</option>
					<option value="Y">是</option>
				</select>
				&nbsp;<span class='einvoiceType' style="display: none">发票类型&nbsp;</span>
					<select id="invoiceType" class="select_1 valid invoiceType" style="visibility: visible;width: 70px;display: none">
						<c:forEach var ="invoiceType" items="${invoiceTypeList}">
							<option value="${invoiceType.code}">${invoiceType.codeName}</option>
						</c:forEach>
					</select>
			</td>
			<th>是否发送电子保单短信：</th>
			<td colspan="1">
				<select id="isEpolicy" class="select_1 valid" onchange="" style="visibility: visible; width: 40px">
					<option value="N">否</option>
					<option value="Y">是</option>
				</select>
			</td>
		</tr>
		<tr>
			<th>基础版特别约定：</th>
			<td colspan="3"><textarea name="specialArran" id="specialArran" rows="5" class="textarea_1" style="resize:none;"></textarea></td>
		</tr>
		<tbody id='updateInfomationDiv'>
		</tbody>
		<tr>
			<th>温馨提示：</th>
			<td colspan="3"><textarea name="notice" id="notice" cols="" rows="5" class="textarea_1" style="resize:none;"></textarea></td>
		</tr>
		</tbody>
	</table>
	<div align="center">
		<input class="input_button_3" id="saveNlifePlanBtn" type="button"  value="保存">&nbsp;&nbsp;
		<input class="input_button_3" id="GoBackNlifePlanBtn" type="button" value="返回" onclick="goBackToList()">
	</div>
</form>

<!-- begin -------------------------产品 DIV 默认隐藏--------------------------->
<div id="nlifeProdDiv"  style="display:none;width:80%;">
	<div class="table_title_div">
		<table class="table_title" style='width:100%;height:20px;'>
			<tr>
				<td width="10%"></td>
				<td width="80%" id="interfaceName"></td>
				<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeNlifeProdDiv()"/></td>
			</tr>
		</table>
	</div>

	<table class="table_02" align="center" >
		<tr>
			<td>
				<table class="search_table">
					<tr height="30px" >
						<td style="border:0px;text-align: right;">交易系统产品代码：</td>
						<td style="border:0px;text-align: left;">
							<input name="txt3"  id="prodCode_choose" class="input_text" style="width:120px;">
						</td>
						<td style="border:0px;text-align: right;">交易系统产品名称：</td>
						<td style="border:0px;text-align: left;">
							<input name="txt3" id="prodName_choose" class="input_text" style="width:120px;">
						</td>
					</tr>
					<tr height="30px" >
						<td style="border:0px;text-align: right;">定义起期：</td>
						<td style="border:0px;text-align: left;">
							<input id="startDateBegin" onkeydown="false" onclick="showCalendar('startDateBegin','y-mm-dd');$('.calendars').css('z-index',20000);" class="input_time" type="text" style="width:120px;"/>
						</td>
						<td style="border:0px;text-align: right;">定义止期：</td>
						<td style="border:0px;text-align: left;">
							<input id="startDateEnd" onkeydown="false" onclick="showCalendar('startDateEnd','y-mm-dd');$('.calendars').css('z-index',20000);" class="input_time" type="text" style="width:120px;"/>
							&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryNlifeProd(1)"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table id="nlifeProdTable"  class="content_table_1">
					<thead>
					<tr class="f1">
						<th style="width:5%">选择</th>
						<th style="width:45%">交易系统产品代码</th>
						<th style="width:50%">交易系统产品描述</th>
					</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
				<div id="nlifeProdPageDIV" class="page"></div>
			</td>
		</tr>
	</table>
	<div align="center" >
		<input class="input_button_3" type="button" onclick="chooseNlifeProd()" value="确定">&nbsp;&nbsp;
		<input class="input_button_3" type="button" onclick="closeNlifeProdDiv()" value="取消">
	</div>
</div>
<!-- end -------------------------产品 DIV 默认隐藏--------------------------->
<!-- begin -----------------------关联信息配置Div 默认隐藏--------------------------->
<div id="unionMessageConfigDiv"  style="display:none;width:80%;">
	<div class="table_title_div">
		<table class="table_title" style='width:100%;height:20px;'>
			<tr>
				<td width="10%"></td>
				<td width="80%" id="interfaceName"></td>
				<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeUnionMessageConfigDiv(),selectUnionMessageConfigAndWriteBack()"/></td>
			</tr>
		</table>
	</div>
	<table class="table_02" align="center" >
		<tr>
			<td>
				<table class="search_table">
					<tr height="30px" >
						<td style="border:0px;text-align: left;" id="unionMessageConfigPlanNoTitle">方案号：</td>
						<td style="border:0px;text-align: left;" id="unionMessageConfigPlanNo"></td>
						<td style="border:0px;text-align: left;" id="unionMessageConfigPlanNameTitle">方案名称：</td>
						<td style="border:0px;text-align: left;" id="unionMessageConfigPlanName"></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>适用机构：
				<select id="unionMessageConfigDept" style="margin-right: 5%" onchange="selectUnionMessageConfigAndWriteBack()">
					<c:if test="${not empty provenceDeptList}">
						<c:forEach items="${provenceDeptList}" var="provenceDept">
							<option value="${provenceDept.deptCode}">${provenceDept.deptCname} - ${provenceDept.deptCode}</option>
						</c:forEach>
					</c:if>
				</select>
				适用车辆座位数：
				<input id="unionMessageConfigMinSeatNum" onkeyup="clearNoNum(event,this)">
				至
				<input id="unionMessageConfigMaxSeatNum" onkeyup="clearNoNum(event,this)" style="margin-right:5%">

				方案性质：
				<select id="unionMessageConfigPlanType" onchange="selectUnionMessageConfigAndWriteBack()">
					<!-- 1意外 2健康 3财产 4责任 -->
					<option value='1'>意外险</option>
					<option value='2'>健康险</option>
					<option value='3'>财产险</option>
					<option value='4'>责任险</option>
				</select>
			</td>
		</tr>
		<tr>

			<td style="text-align: left">
				&nbsp;&nbsp;适用车辆性质：
			</td>
		</tr>
		<tr>
			<td>
				<c:if test="${not empty carNatureList}">
					<c:forEach items="${carNatureList}" var="carNature">
						<input style="margin-left: 5px" type="checkbox" name="carNatureSelector" id="carNatureSelector"  value="${carNature.code}"  title="${carNature.code}"> ${carNature.codeName}
					</c:forEach>
				</c:if>
			</td>
		</tr>
		<tr>
			<td style="text-align: left">
				&nbsp;&nbsp;服务代码：
				<input type="text" name="carNlifeServiceCode" id="carNlifeServiceCode" style="width: 500px">
			</td>
		</tr>
		<tr>
			<td><input type="button" onclick='saveUnionMessageConfig()' value="确定"/>&nbsp&nbsp<input type="button" onclick="closeUnionMessageConfigDiv()" value="取消"> </td>
		</tr>
	</table>
</div>
<div id="carNatureSelecDiv"  style="display:none;width:80%;">
	<ul>

	</ul>
</div>
<!-- end -------------------------关联信息配置Div 默认隐藏--------------------------->


<!-- begin --------------------------- 合作伙伴 DIV--------------------------->
<div id="channelInfoDiv" style="display:none;width:80%;">
	<div class="table_title_div">
		<table class="table_title" style='width:100%;height: 20px;'>
			<tr>
				<td width="10%"></td>
				<td width="80%" id="interfaceName"></td>
				<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeChannelInfoDiv()"/></td>
			</tr>
		</table>
	</div>
	<table class="table_02" style="width:98%">
		<tr>
			<td>
				<table class="search_table">
					<tr height="30px">
						<td colspan="3" style="text-align:center">
							合作伙伴代码：<input name="txt3"  id="channelCode_choose" class="input_text" />&nbsp;&nbsp;
							合作伙伴名称：<input name="txt3" id="channelName_choose" class="input_text" />&nbsp;&nbsp;
							<input type="button"  class="input_button_1" value="查询" onClick="queryChannelInfo(1)"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table id="channelInfoTable"  class="content_table_1">
					<thead>
					<tr class="f1">
						<th style="width:5%">选择</th>
						<th style="width:10%">合作伙伴代码</th>
						<th style="width:20%">合作伙伴名称</th>
					</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
				<div id="channelInfoPageDIV"  class="page"></div>
			</td>
		</tr>
	</table>
	<div align="center">
		<input type="button" value="确定" onclick="chooseChannelInfo()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		<input type="button" value="取消" onclick="closeChannelInfoDiv()" class="input_button_3"/>
	</div>
</div>
<!-- end --------------------------- 合作伙伴 DIV--------------------------->

<!-- begin ------------------------出单机构 DIV 默认隐藏--------------------------->
<div id="deptDiv" style="display:none;width:80%;">
	<div class="table_title_div">
		<table class="table_title" style='width:100%;height: 20px;'>
			<tr>
				<td width="10%"></td>
				<td width="80%" id="interfaceName"></td>
				<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeDeptDiv()"/></td>
			</tr>
		</table>
	</div>
	<table class="table_02" style="height:180px;" align="center">
		<tr>
			<td>
				<table class="search_table">
					<tr height="30px">
						<td colspan="3" style="text-align:center">
							出单机构代码：<input name="txt3"  id="deptCode_choose" class="input_text" />&nbsp;&nbsp;
							出单机构名称：<input name="txt3" id="deptCname_choose" class="input_text" />
							<input type="button"  class="input_button_1" value="查询" onClick="queryDept(1)"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table id="deptTable"  class="content_table_1">
					<thead>
					<tr class="f1">
						<th style="width:5%">选择</th>
						<th style="width:45%">出单机构代码</th>
						<th style="width:50%">出单机构名称</th>
					</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
				<div id="deptPageDIV"  class="page"></div>
			</td>
		</tr>
	</table>
	<div align="center" >
		<input type="button" value="确定" onclick="chooseDept()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		<input type="button" value="取消" onclick="closeDeptDiv()" class="input_button_3"/>
	</div>
</div>
<!-- end ------------------------出单机构 DIV 默认隐藏--------------------------->
<!-- begin ----------------------配置个人销售业务信息 Div------------------------>
<div id="agentInfo3Div"  style="display:none;width:1000px; height:450px; ">
	<div class="table_title_div" style="width: 1000px">
		<table class="table_title" style='width:1000px;height: 20px;'>
			<tr>
				<td width="120px"></td>
				<td width="1160px" id="interfaceName"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentInfoDiv('agentInfo3Div')"/></td>
			</tr>
		</table>
	</div>
	<div style="width:1000px;height:400px; overflow:scroll;">
		<table class="table_02" style="width:1840px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
								配置状态：<select id="confStatus_3"><option value="">全部</option><option value="Y">已配置</option><option value="N">未配置</option></select>&nbsp;&nbsp;
								用户名：<input id="userCode" class="input_text" />&nbsp;&nbsp;
								姓名：<input id="userName" class="input_text" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryAgentInfo3(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentInfo3Table"  class="content_table_1">
						<thead>
						<tr class="f1">
							<th style="width:40px"><input id="agentInfo3CheckAll" type="checkbox"></th>
							<th style="width:100px">用户名</th>
							<th style="width:100px">姓名</th>
							<th style="width:100px">出单机构</th>
							<th style="width:100px">服务代码</th>
							<th style="width:100px">服务名称</th>
							<th style="width:100px">业务员代码</th>
							<th style="width:100px">业务员名称</th>
							<th style="width:100px">单证领用人</th>
							<th style="width:100px">团队代码 </th>
							<th style="width:100px">归属渠道</th>
							<th style="width:100px">渠道类型</th>
							<th style="width:100px">业务来源</th>
							<th style="width:100px">代理人编码 </th>
							<th style="width:100px">代理协议号</th>
							<th style="width:100px">代理人名称</th>
							<th style="width:100px">处理人</th>
							<th style="width:100px">手续费比例 </th>
							<th style="width:100px">市场维护费比例 </th>
							<th style="width:100px">业务绩效比例</th>
						</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentInfo3Page" class="page"></div>
				</td>
			</tr>
		</table>
	</div>
	<div align="center" >
		<input type="button" value="保存" onclick="saveChosenAgentInfo3()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		<input type="button" value="取消" onclick="closeAgentInfoDiv('agentInfo3Div')" class="input_button_3"/>
	</div>
</div>
<!-- end ----------------------配置个人销售业务信息 Div------------------------>
<!-- begin ----------------------配置激活卡销售业务信息 Div------------------------>
<div id="agentInfo7Div"  style="display:none;width:1000px; height:450px; ">
	<div class="table_title_div" style="width: 1000px">
		<table class="table_title" style='width:1000px;height: 20px;'>
			<tr>
				<td width="120px"></td>
				<td width="1160px" id="interfaceName"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentInfoDiv('agentInfo7Div')"/></td>
			</tr>
		</table>
	</div>
	<div style="width:1000px;height:400px; overflow:scroll;">
		<table class="table_02" style="width:1840px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
								配置状态：<select id="confStatus_7"><option value="">全部</option><option value="Y">已配置</option><option value="N">未配置</option></select>&nbsp;&nbsp;
								用户名：<input id="userCodeCard" class="input_text" />&nbsp;&nbsp;
								姓名：<input id="userNameCard" class="input_text" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryAgentInfo7(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentInfo7Table"  class="content_table_1">
						<thead>
						<tr class="f1">
							<th style="width:40px"><input id="agentInfo7CheckAll" type="checkbox"></th>
							<th style="width:100px">用户名</th>
							<th style="width:100px">姓名</th>
							<th style="width:100px">出单机构</th>
							<th style="width:100px">服务代码</th>
							<th style="width:100px">服务名称</th>
							<th style="width:100px">业务员代码</th>
							<th style="width:100px">业务员名称</th>
							<th style="width:100px">单证领用人</th>
							<th style="width:100px">团队代码 </th>
							<th style="width:100px">归属渠道</th>
							<th style="width:100px">渠道类型</th>
							<th style="width:100px">业务来源</th>
							<th style="width:100px">代理人编码 </th>
							<th style="width:100px">代理协议号</th>
							<th style="width:100px">代理人名称</th>
							<th style="width:100px">处理人</th>
							<th style="width:100px">手续费比例 </th>
							<th style="width:100px">市场维护费比例 </th>
							<th style="width:100px">业务绩效比例</th>
						</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentInfo7Page" class="page"></div>
				</td>
			</tr>
		</table>
	</div>
	<div align="center" >
		<input type="button" value="保存" onclick="saveChosenAgentInfo7()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		<input type="button" value="取消" onclick="closeAgentInfoDiv('agentInfo7Div')" class="input_button_3"/>
	</div>
</div>
<!-- end ----------------------配置激活卡销售业务信息 Div------------------------>
<!-- begin ----------------------配置总对总销售业务信息 Div------------------------>
<div id="agentInfo4Div" style="display:none;width:1000px; height:450px; ">
	<div class="table_title_div" style="width: 1000px">
		<table class="table_title" style='width:1000px;height: 20px;'>
			<tr>
				<td width="120px"></td>
				<td width="1260px" id="interfaceName"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentInfoDiv('agentInfo4Div')"/></td>
			</tr>
		</table>
	</div>
	<div class="table_title_div" style="width: 1000px;height:400px; overflow:scroll;">
		<table class="table_02" style="width:1840px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:left">
								配置状态：<select id="confStatus_4"><option value="">全部</option><option value="Y">已配置</option><option value="N">未配置</option></select>&nbsp;
								网点代码：<input id="branch" class="input_text" style="width:90px"/>&nbsp;
								网点名称：<input id="branchName" class="input_text" style="width:90px"/>&nbsp;
								出单机构：<input id="deptId" class="input_text" style="width:90px"/>&nbsp;
								机构名称：<input id="deptName" class="input_text" style="width:90px"/>&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryAgentInfo4(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentInfo4Table"  class="content_table_1" style=' overflow:scroll;'>
						<thead>
						<tr class="f1">
							<th style="width:40px"><input id="agentInfo4CheckAll" type="checkbox"></th>
							<th style="width:80px">网点代码</th>
							<th style="width:100px">网点名称</th>
							<th style="width:80px">用户名</th>
							<th style="width:80px">姓名</th>
							<th style="width:80px">出单机构</th>
							<th style="width:80px">机构名称</th>
							<th style="width:80px">服务代码</th>
							<th style="width:80px">服务名称</th>
							<th style="width:80px">业务员代码</th>
							<th style="width:80px">业务员名称</th>
							<th style="width:80px">单证领用人 </th>
							<th style="width:80px">团队代码 </th>
							<th style="width:90px">归属渠道</th>
							<th style="width:90px">渠道类型</th>
							<th style="width:80px">业务来源</th>
							<th style="width:80px">代理人编码</th>
							<th style="width:80px">代理协议号</th>
							<th style="width:80px">代理人姓名</th>
							<th style="width:80px">处理人</th>
							<th style="width:80px">手续费比例 </th>
							<th style="width:85px">市场维护费比例</th>
							<th style="width:80px">业务绩效比例 </th>
						</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentInfo4Page"  class="page"></div>
				</td>
			</tr>
		</table>
	</div>
	<div align="center" >
		<input type="button" value="保存" onclick="saveChosenAgentInfo4()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		<input type="button" value="取消" onclick="closeAgentInfoDiv('agentInfo4Div')" class="input_button_3" id='cancelBtn'/>
	</div>
</div>
<!-- end ----------------------配置总对总销售业务信息 Div------------------------>
<!-- 配置总对总区域业务信息 -->
<div id="agentInfoZon4Div" style="display:none;width:810px; height:400px; ">
	<div class="table_title_div" style="width: 800px">
		<table class="table_title" style='width:800px;height: 20px;'>
			<tr>
				<td width="120px"></td>
				<td width="700px"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentInfoDiv('agentInfoZon4Div')"/></td>
			</tr>
		</table>
	</div>
	<div class="table_title_div" style="width: 800px;height:350px; overflow:scroll;">
		<table class="table_02" style="width:780px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
								配置状态：<select id="ZonconfStatus_4"><option value="">全部</option><option value="Y">已配置</option><option value="N">未配置</option></select>&nbsp;&nbsp;
								分公司名称：<input id="ZonbranchName" class="input_text" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryAgentInfoZon4(1)"/>
							</td>
						</tr>
						<tr height="10px">
							<td colspan="10" style="text-align: right;">
								<span style="margin-left: -5px" class="red">说明：手续费比例，业务绩效比例，市场维护费比例填写时，若比例为10%，请填写0.1</span>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentInfoZon4Table"  class="content_table_1" style=' overflow:scroll;'>
						<thead>
						<tr class="f1">
							<th style="width:40px">选择</th>
							<th style="width:80px">分公司代码</th>
							<th style="width:100px">分公司名称</th>
							<th style="width:180px">手续费比例 </th>
							<th style="width:185px">市场维护费比例</th>
							<th style="width:180px">业务绩效比例 </th>
						</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentInfoZon4Page"  class="page"></div>
				</td>
			</tr>
		</table>
	</div>
	<div align="center" >
		<input type="button" value="保存" onclick="saveChosenZonAgentInfo4()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		<input type="button" value="取消" onclick="closeAgentInfoDiv('agentInfoZon4Div')" class="input_button_3"/>
	</div>
</div>
<!-- 配置总对总区域业务信息 结束-->

<!-- 配置联合出单区域业务信息 -->
<div id="agentInfoZon5Div" style="display:none;width:810px; height:400px; ">
	<div class="table_title_div" style="width: 800px">
		<table class="table_title" style='width:800px;height: 20px;'>
			<tr>
				<td width="120px"></td>
				<td width="700px"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentInfoDiv('agentInfoZon5Div')"/></td>
			</tr>
		</table>
	</div>
	<div class="table_title_div" style="width: 800px;height:350px; overflow:scroll;">
		<table class="table_02" style="width:780px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
								配置状态：<select id="ZonconfStatus_5"><option value="">全部</option><option value="Y">已配置</option><option value="N">未配置</option></select>&nbsp;&nbsp;
								分公司名称：<input id="ZonbranchName5" class="input_text" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryAgentInfoZon5(1)"/>
							</td>
						</tr>
						<tr height="10px">
							<td colspan="10" style="text-align: right;">
								<span style="margin-left: -5px" class="red">说明：手续费比例，业务绩效比例，市场维护费比例填写时，若比例为10%，请填写0.1</span>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentInfoZon5Table"  class="content_table_1" style=' overflow:scroll;'>
						<thead>
						<tr class="f1">
							<th style="width:40px">选择</th>
							<th style="width:80px">分公司代码</th>
							<th style="width:100px">分公司名称</th>
							<th style="width:180px">手续费比例 </th>
							<th style="width:185px">市场维护费比例</th>
							<th style="width:180px">业务绩效比例 </th>
						</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentInfoZon5Page"  class="page"></div>
				</td>
			</tr>
		</table>
	</div>
	<div align="center" >
		<input type="button" value="保存" onclick="saveChosenZonAgentInfo5()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		<input type="button" value="取消" onclick="closeAgentInfoDiv('agentInfoZon5Div')" class="input_button_3"/>
	</div>
</div>
<!-- 配置联合出单区域业务信息 结束-->


<!--广东分公司配置销售人员信息div-->
<div id="sale_div" style="display:none;width:1000px; height:450px;">
	<div class="table_title_div" style="width: 990px">
		<table class="table_title" style='width:990px;height: 20px;'>
			<tr>
				<td width="120px"></td>
				<td width="1460px" id="interfaceName"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeNocarAgentTypeDiv('sale_div')"/></td>
			</tr>
		</table>
	</div>
	<table class="table_02" id="table" style="width:990px;" align="center">
		<tr>
			<td>
				<table id="sale3"  class="content_table_1">
					<thead>
					<tr class="f1">
						<th style="width:90px">序号</th>
						<th style="width:110px">销售员类别<span style="margin-left: -5px" class="red">*</span></th>
						<th style="width:90px">销售人员代码<span style="margin-left: -5px" class="red">*</span></th>
						<th style="width:90px">销售人员名称</th>
						<th style="width:90px">执业证号</th>
						<th style="width:90px">代理机构号</th>
						<th style="width:90px">代理人机构名称</th>
						<th style="width:90px">分摊比例<span style="margin-left: -5px" class="red">*</span></th>
					</tr>
					</thead>
					<tbody id='salecontent'>
					</tbody>
				</table>
			</td>
		</tr>
	</table>
	<div align="center" >
		<input type="button" id="saveSaleBtn" value="保存" onclick="saveSale()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		<input type="button" value="取消" onclick="closeNocarAgentTypeDiv('sale_div')" class="input_button_3"/>
	</div>
</div>
<!-- 广东人员销售配置结束 -->
<!-- begin ----------------------配置联合出单销售业务信息 Div------------------------>
<div id="agentInfo5Div" style="display:none;width:1000px; height:450px; ">
	<div class="table_title_div" style="width: 1000px">
		<table class="table_title" style='width:1000px;height: 20px;'>
			<tr>
				<td width="120px"></td>
				<td width="1260px" id="interfaceName"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentInfoDiv('agentInfo5Div')"/></td>
			</tr>
		</table>
	</div>
	<div class="table_title_div" style="width: 1000px;height:400px; overflow:scroll;">
		<table class="table_02" style="width:1840px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
								配置状态：<select id="confStatus_5"><option value="">全部</option><option value="Y">已配置</option><option value="N">未配置</option></select>&nbsp;&nbsp;
								Key1：<input id="key1" style="width: 120px;" />&nbsp;
								Key2：<input id="key2" style="width: 120px;" />&nbsp;
								Key3：<input id="key3" style="width: 120px;" />&nbsp;
								Key4：<input id="key4" style="width: 120px;" />&nbsp;
								Key5：<input id="key5" style="width: 120px;" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryAgentInfo5(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentInfo5Table"  class="content_table_1" style=' overflow:scroll;'>
						<thead>
						<tr class="f1">
							<th style="width:40px"><input id="agentInfo5CheckAll" type="checkbox"></th>
							<th style="width:80px">出单机构</th>
							<th style="width:80px">服务代码</th>
							<th style="width:80px">服务名称</th>
							<th style="width:80px">业务员代码</th>
							<th style="width:80px">业务员名称</th>
							<th style="width:80px">单证领用人 </th>
							<th style="width:80px">团队代码 </th>
							<th style="width:90px">归属渠道</th>
							<th style="width:90px">渠道类型</th>
							<th style="width:90px">业务来源</th>
							<th style="width:80px">代理人编码</th>
							<th style="width:80px">代理协议号</th>
							<th style="width:80px">代理人姓名</th>
							<th style="width:80px">处理人</th>
							<th style="width:80px">Key1 </th>
							<th style="width:80px">Key2 </th>
							<th style="width:80px">Key3 </th>
							<th style="width:80px">Key4 </th>
							<th style="width:80px">Key5 </th>
							<th style="width:80px">手续费比例 </th>
							<th style="width:85px">市场维护费比例</th>
							<th style="width:80px">业务绩效比例 </th>
						</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentInfo5Page"  class="page"></div>
				</td>
			</tr>
		</table>
	</div>
	<div align="center" >
		<input type="button" value="保存" onclick="saveChosenAgentInfo5()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		<input type="button" value="取消" onclick="closeAgentInfoDiv('agentInfo5Div')" class="input_button_3"/>
	</div>
</div>
<!-- end ----------------------配置联合出单销售业务信息 Div------------------------>
<!--接口传入方案-->
<div id="agentInfo6Div" style="display:none;width:800px; height:350px; ">
	<div class="table_title_div" >
		<table class="table_title" style='height: 20px;'>
			<tr>
				<td width="120px"></td>
				<td width="1260px" id="interfaceName"></td>
				<td align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeAgentInfoDiv('agentInfo6Div')" style="float: ri"/></td>
			</tr>
		</table>
	</div>
	<div class="table_title_div" style="height:300px; overflow:scroll;">
		<table class="table_02"  align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
								跟单配置代码：<input id="agentNoSer" class="input_text" />&nbsp;&nbsp;
								跟单配置名称：<input id="agentNameSer" class="input_text" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryAgentInfo6(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentInfo6Table"  class="content_table_1" style=' overflow:scroll;'>
						<thead>
						<tr class="f1">
							<th >选择</th>
							<th >跟单配置代码</th>
							<th>跟单配置名称</th>
						</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentInfo6Page"  class="page"></div>
				</td>
			</tr>
		</table>
	</div>
	<div align="center" >
		<input type="button" value="保存" onclick="saveChosenAgentInfo6()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		<input type="button" value="取消" onclick="closeAgentInfoDiv('agentInfo6Div')" class="input_button_3"/>
	</div>
</div>
<!-- 接口传入方案 -->
<input type="hidden" id='isThirdPlan'>

<!-- 详情页面开始 -->
<div id="productDetail"
	 style="display:none ; width: 65%; height: 75%; padding-bottom: 10px; margin-top: -50px; overflow-y: auto;">
	<div class="table_title_div">
		<table class="table_title" style='width: 100%; height: 20px;'>
			<tr>
				<td width="10%"></td>
				<td width="80%" id="interfaceName"></td>
				<td width="10%" align="right"><img
						src="<%=path %>/images/closedown.gif" alt="关闭"
						onclick="closeDetailDiv()" /></td>
			</tr>
		</table>
	</div>
	<div>
		<ul style="padding-top: 8px;">
			<li style="float: left; width: 50%; margin-left: 2%"><h5 class="productInfo">产品信息</h5></li>
			<li style="float: left; width: 40%"><span id="algorithmeExport"
													  style="height: 30px; line-height: 30px; text-indent: 10px;"><a  href="javascript:void(0)" onclick = "exportCovDetail(this)">算法导出 </a></span></li>
		</ul>
	</div>
	<table class="table_02" align="center" style="width: 95%;">
		<tr>
			<td style="text-align: right; border-right: 0px;" width="15%">产品代码：</td>
			<td style="text-align: left; padding-left: 6px; border-right: 0px;"
				width="35%"><span id="prod_no"></span></td>
			<td style="text-align: right; border-right: 0px;" width="15%">产品名称：</td>
			<td style="text-align: left; padding-left: 6px;" width="35%"><span
					id="prod_name"></span></td>
		</tr>
		<tr>
			<td style="text-align: right; border-right: 0px;" width="15%">最长延时起保天数：</td>
			<td style="text-align: left; padding-left: 6px; border-right: 0px;"
				width="35%"><span id="max_delay_day"></span></td>
			<td style="text-align: right; border-right: 0px;" width="15%">最短延时起保天数：</td>
			<td style="text-align: left; padding-left: 6px;" width="35%"><span
					id="min_delay_day"></span></td>
		</tr>
		<tr>
			<td style="text-align: right; border-right: 0px;" width="15%">最长起保后注销天数:</td>
			<td style="text-align: left; padding-left: 6px; border-right: 0px;"
				width="35%"><span id="max_cancle_day"></span></td>
			<td style="text-align: right; border-right: 0px;" width="15%">保险期间:</td>
			<td style="text-align: left; padding-left: 6px;" width="35%"><span
					id="start_date"></span></td>
		</tr>
		<tr>
			<td style="text-align: right; border-right: 0px;" width="15%">是否及时起保:</td>
			<td style="text-align: left; padding-left: 6px; border-right: 0px;"
				width="35%"><span id="instant"></span></td>
			<td style="text-align: right; border-right: 0px;" width="15%">最大份数:</td>
			<td style="text-align: left; padding-left: 6px;" width="35%"><span
					id="max_Number"></span></td>
		</tr>
	</table>


	<div id="nlife_div_drive_xz_tableInfo" style="display: block; width: 100%;">
		<table id="nlife_risk_cov_detail" class="content_table_1" align="center"
			   style="width: 100%;">
			<tbody>
			</tbody>
		</table>
	</div>
	<div id="nlife_div_driver_xz_tableInfo" style="display: block;width:95%">

		<table class="table_02" id="nlife_cov_detail" align="center" style="width: 95%;">
			<tbody>
			</tbody>
		</table>
	</div>

</div>
</div>
<!-- 结束 -->

</body>
</html>
